I just saw an example of routing in AngularJS. I would like to know the relation ship between dependency 'ngRoute'
and module mainApp
, in synatx var mainApp = angular.module("mainApp", ['ngRoute']);
.
Previously I've seen examples with empty square brackets in module declaration.
Below is the whole context of code:
var mainApp = angular.module("mainApp", ['ngRoute']);
mainApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/addStudent', {
templateUrl: 'addStudent.htm',
controller: 'AddStudentController'
}).
when('/viewStudents', {
templateUrl: 'viewStudents.htm',
controller: 'ViewStudentsController'
}).
otherwise({
redirectTo: '/addStudent'
});
}]);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…