I have been trying to dynamically change the array number of my expression. My initial state:
<p class="title text-center">{{data[0].title}}</p>
<p class="subtitle text-center">{{data[0].sub_title}}</p>
Data is just an array returned from an http request. What I want is that when I click or swipe an element on the page that it jumps to the second item in the data array, e.g.:
<p class="title text-center">{{data[1].title}}</p>
<p class="subtitle text-center">{{data[1].sub_title}}</p>
I have been trying to make an expression in an expression, but I think that that is very wrong. Also, I have tried adding a variable to the $scope in the controller:
$scope.update = function (whateverispassedinfromotherfunction){
var item = whateverispassedinfromotherfunction;
return "data["+whateverispassedinfromotherfunction+"].sub_title";
}
and then this in the HTML
<p class="subtitle text-center">{{update}}</p>
but that does not make any sense to Angular and to me neither :).
Anyone that knows a solution?