-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
63 lines (47 loc) · 1.59 KB
/
Copy pathscript.js
File metadata and controls
63 lines (47 loc) · 1.59 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
// create the module and name it booksApp
var booksApp = angular.module('booksApp', ['ngRoute']);
// configure our routes
booksApp.config(function($routeProvider) {
$routeProvider
// route for the home page
.when('/', {
templateUrl : 'SPA/pages/home.html',
controller : 'mainController'
})
// route for the about page
.when('/about/:restId', {
templateUrl : 'SPA/pages/about.html',
controller : 'aboutController'
})
// route for the contact page
.when('/contact', {
templateUrl : 'SPA/pages/contact.html',
controller : 'contactController'
});
});
// create the controller and inject Angular's $scope
booksApp.controller('mainController', function($scope, $http) {
// create a message to display in our view
$http({method: 'GET', url: 'http://localhost:8003/rest'}).
success(function(data, status, headers, config) {
$scope.messages = data;
}).
error(function(data, status, headers, config) {
});
});
booksApp.controller('aboutController', function($scope,$http,$routeParams) {
$http({method: 'GET', url: 'http://localhost:8003/rest/'+$routeParams.restId}).
success(function(data, status, headers, config) {
$scope.message = data;
}).
error(function(data, status, headers, config) {
});
});
booksApp.controller('contactController', function($scope,$http) {
$http({method: 'GET', url: 'http://localhost:8003/rest/1'}).
success(function(data, status, headers, config) {
$scope.messages = data;
}).
error(function(data, status, headers, config) {
});
});