【angular】笔记 angular.modules

angular.module 创建、获取、注册angular中的模块

//创建一个新模块,空数组代表该数组不依赖其他模块
var createModule = angular.module("createMd",[]);

//只有一个参数(模块),代表获取模块
//如果模块不存在,angular会抛出异常
var getModule = angular.module("getMd");

//返回true,因为是同一个模块
alert( createModule == getModule );

 

该函数既可以创建新的模块,也可以获取已有模块,具体是创建还是获取,依靠参数数量来区分 。

angular.module(name, [requires], [configFn]);

name:       字符串类型,代表模块名称

requires:   字符串数组,代表该模块依赖的其余模块,如果不依赖其他模块,则用空数组链接即可

configFn:    用来对该模块进行一些配置

 

You can think of a module as a container for the different part of your app - controllers、services、directives、filters 、etc

posted @ 2016-03-09 09:27  梁哥  阅读(151)  评论(0编辑  收藏  举报