I want to loop through several json object arrays with one ng-click.
Example - Please see following Plunker: https://plnkr.co/edit/7P4Oha5OdfTC5wndUebE?p=preview
When I click now on one of my blue numbers (anyway which item), it should change to the next one for all items. At the moment, the other item disappears.
So at the end, all items should always have the same number value, when I click on it.
How can I do that ? Thanks for your help...
(function () {
'use strict';
angular
.module('app', [])
.controller('myctrl', myctrl);
function myctrl($scope, $http) {
$http.get("data.json")
.success(function (data) {
$scope.data = data;
$scope.nbr = 0;
});
$scope.next = function (dataId, nbr) {
$scope.nbr = ($scope.nbr + 1) % $scope.data.data[dataId].numbers.length;
};
$scope.change = function (dataId, nbr) {
$scope.data.data[dataId].numbers[nbr].bench = $scope.data.data[dataId].numbers[nbr].number1 +
$scope.data.data[dataId].numbers[nbr].number2 +
$scope.data.data[dataId].numbers[nbr].number3;
}
}
})();