1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 | var dataBank = [
{first: 'Jackson' , last: 'Pollock'} ,
{first: 'George' , last: 'Washington'} ,
{first: 'Richard', last: 'Hatch'}
];
var app = angular.module("myApp", []);
app.controller("recordViewer", function($scope) {
$scope.recordIndex = 0;
$scope.nextRecord = function() {
$scope.recordIndex++;
if ($scope.recordIndex > 2) {
$scope.recordIndex = 0;
}
$scope.currentRecord = {first: dataBank[$scope.recordIndex].first ,
last : dataBank[$scope.recordIndex].last};
};
});
|