-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
executable file
·45 lines (39 loc) · 1.52 KB
/
app.js
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
// modules are like the main methods in angular. The first parameter is the app name and the second is an array of dependencies of the app.
var emersonAngularApp = angular.module('EmersonAngularApp', ['ngRoute', 'swapi']);
// configure the routing for this app: i.e. set the controller when you hit a view. e.g. when the template url hits views/main.html, use the Main controller.
/*
If you want to navigate to different pages in your application, but you also want the application to be a SPA (Single Page Application), with no page reloading, you can use the ngRoute module.
The ngRoute module routes your application to different pages without reloading the entire application.
Live example: https://www.w3schools.com/angular/tryit.asp?filename=try_ng_routing
*/
emersonAngularApp.config(['$routeProvider',
function($routeProvider){
$routeProvider
.when('/', {
templateUrl : 'views/main.html',
controller : 'MainCtrl',
controllerAs : 'main'
})
.when('/character/:id', {
templateUrl: 'views/character.html',
controller: 'CharacterCtrl',
controllerAs: 'character'
})
.when('/movie/:id', {
templateUrl: 'views/movie.html',
controller: 'MovieCtrl',
controllerAs: 'movie'
})
.when('/specie/:id', {
templateUrl: 'views/specie.html',
controller: 'SpecieCtrl',
controllerAs: 'specie'
})
.when('/planet/:id', {
templateUrl: 'views/planet.html',
controller: 'PlanetCtrl',
controllerAs: 'planet'
})
.otherwise('/');
}
]);