-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirstpage.html
More file actions
63 lines (58 loc) · 1.38 KB
/
Copy pathfirstpage.html
File metadata and controls
63 lines (58 loc) · 1.38 KB
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
58
59
60
61
62
63
<!DOCTYPE html>
<html data-ng-app = "myApp">
<head>
<title>Getting data</title>
</head>
<body>
<div>
<div data-ng-view=""></div>
</div>
<script src="angular.js"></script>
<script src="angular-route.js" type="text/javascript"></script>
<script type="controller.js"></script>
<script>
var myApp = angular.module("myApp", ['ngRoute']);
myApp.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/view1',
{
controller: 'SimpleController',
templateUrl: 'Partials/View1.html'
})
.when('/view2',
{
controller: 'SimpleController',
templateUrl: 'Partials/View2.html'
})
.otherwise({ redirectTo: '/view1'});
}]);
myApp.factory("SimpleFactory", function(){
var factory = {};
var customers = [
{ name:'John Smith', city: 'Pheonix' },
{ name:'John Doe', city: 'New York' },
{ name:'Jane Doe', city: 'San Francisco' }
];
factory.getCustomers = functions(){
return customers;
};
return factory;
});
myApp.controller('SimpleController', function ($scope, SimpleFactory) {
$scope.customers = [];
init();
function init() {
$scope.customers = SimpleFactory.getCustomers();
}
$scope.addCustomer = function() {
$scope.customers.push(
{
name: $scope.newCustomer.name,
city: $scope.newCustomer.city
}
);
};
});
</script>
</body>
</html>