Hi!
i use this concept:
http://learn.ionicframework.com/formulas/sharing-data-between-views/
I would like insert two button in detail state. These buttons control the list ( < prev or next > ).
$scope.nextitem = function(){
n = n+1;
$scope.todo = todos[n];
};
The problem: in the detail view are data (from json) and comment button, and if i click nextitem button, data changed, but if i click comment button, this show the first clicked item comment, not the nextitem (solution maybe change dynamic url??)
or how to use next and prev item?
Thanks!
i create a sample page (in array are three item):
http://yesno.hu/nextitemproblem/
in the heading of browser nothing changed when i use first element of list and use the next button (only data changed), so this is my problem
this is array:
{
id: '1',
name: 'Pick up apples',
done: false
},
{
id: '2',
name: 'Mow the lawn',
done: true
},
{
id: '3',
name: 'Pancake',
done: true
}
click Pick up apples - address bar display 1
click Mow the lawn - address bar display 2
click Pancake - address bar display 3
and
click Pick up apples - address bar display 1
here clicked a next button - display Mow the lawn - address bar display 1
clicked a next button - display Pancake - address bar display 1
how to change this?
Here is the solution in this situation:
var n = 0;
var next_item = “”;
//act_url = :todoID (actual url)
var act_url = $stateParams.todoId;
//Actual item [key]
angular.forEach(TodosService.todos, function(todo, key) {
if (todo.id === act_url) {
n = key;
}
})
//next button
$scope.next = function (){
n = n + 1 ;
next_item = TodosService.todos[n];
$state.go('todo', { todoId: next_item.id });
}
})