I have a simple app that lists "cars" by one from array. When user clicks button, next car from array is shown.
controller:
var parking = angular.module("parking", []); // Registering the parkingCtrl to the parking module parking.controller("parkingCtrl", function ($scope) { // Binding the car’s array to the scope $scope.cars = [ {plate: '6MBV006'}, {plate: '5BBM299'}, {plate: '5AOJ230'} ]; $scope.idx = 0; $scope.next = function(){ $scope.idx = $scope.idx+1; if ($scope.idx>=$scope.cars.length) $scope.idx = 0; } }); "view":
<tr ng-repeat="(i,car) in cars" ng-show="i==idx" > <!-- Showing the car’s plate --> <td>{{car.plate}}</td> </tr> <button ng-click="next()">next</button> How can I show several different arrays of cars on a single page this way, each array with it's own controls (in this case the only control is the "magic" button)?
UPD: I could, of course, just create a required nuber of ng-apps, each with it's own copy of controller ("parkingCtrl1", "parkingCtrl2"..."parkingCtrl10"). But I guess it's not the best way :)