什么是方括号中的意思是“.module(QUOT; MODULENAME&QUOT,[...])”AngularJS的 [英] What is the meaning of the square brackets in “.module("modulename", […])” of AngularJS

查看:325
本文介绍了什么是方括号中的意思是“.module(QUOT; MODULENAME&QUOT,[...])”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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆