-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroutesExample.html
59 lines (51 loc) · 1.34 KB
/
routesExample.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html ng-app="app">
<head>
<title>Sample Angular JS application - Routes example</title>
<script src="angular.min.js" type="text/javascript"></script>
<script src="angular-route.min.js" type="text/javascript"></script>
<script>
// Note: From Angular 1.3+ , we need to register the controllers
// using the below syntax
var app = angular.module('app',['ngRoute']);
app.config(function ($routeProvider) {
$routeProvider
.when('/', {
controller : 'SimpleController',
templateUrl : 'routes/view1.html'
})
.when('/view2', {
controller : 'SimpleController',
templateUrl : 'routes/view2.html'
})
.otherwise({
redirectTo: '/'
});
});
app.controller('SimpleController',['$scope',
function ($scope) {
$scope.customers = [
{name: 'Akshay Kumar' , city: 'Chandigarh'},
{name: 'Madhuri Dixit' , city: 'Mumbai'},
{name: 'Shah Rukh Khan' , city: 'Delhi'},
{name: 'Anil Kumble' , city: 'Bangalore'},
{name: 'Rishi Kanitkar' , city: 'Pune'},
{name: 'Dhanraj Pillai' , city: 'Pune'}
];
$scope.addCustomer = function() {
$scope.customers.push(
{
name: $scope.newCustomer.name ,
city: $scope.newCustomer.city
});
}
}]);
</script>
</head>
<body>
<div>
<!-- Placeholder for the views -->
<div ng-view=""></div>
</div>
</body>
</html>