什么是方括号中的意思是“.module(QUOT; MODULENAME&QUOT,[...])”AngularJS的 [英] What is the meaning of the square brackets in “.module("modulename", […])” of AngularJS
问题描述
我刚刚看到一个例如在AngularJS路由的。我想知道的依赖性'ngRoute
和模块 mainApp
之间的关系的船,在synatx VAR mainApp = angular.module(mainApp,['ngRoute']);
previously我已经看到了空方括号例子,模块声明。
下面是code的整个来龙去脉:
VAR mainApp = angular.module(mainApp,['ngRoute']); mainApp.config(['$ routeProvider',
功能($ routeProvider){
$ routeProvider。
当('/传递addStudent',{
templateUrl:addStudent.htm',
控制器:'AddStudentController
})。
当('/ viewStudents',{
templateUrl:viewStudents.htm',
控制器:'ViewStudentsController
})。
除此以外({
redirectTo:/传递addStudent
});
}]);
[...]
定义了一个数组
在角情况。
mainApp
是主模块(主阵列)和 ngRoute
的一个子模块(如对象数组) 。
该示例是
VAR ngRoute = []; // {}VAR mainApp = [ngRoute]; //现在`mainApp`包括`ngRoute`
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'
});
}]);
[...]
defines an array
In the angular case.
mainApp
is a main module( main array) and ngRoute
is a sub module(like array of object).
The sample is
var ngRoute=[];//{}
var mainApp=[ngRoute];// now the `mainApp` includes the `ngRoute`
这篇关于什么是方括号中的意思是“.module(QUOT; MODULENAME&QUOT,[...])”AngularJS的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!