首页 > 其他 > 详细

angular.module

时间:2016-02-26 16:58:24      阅读:176      评论:0      收藏:0      [点我收藏+]

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

创建:两个或更多参数

获取:只有一个参数

The angular.module() is a global place for creating, registering and retrieving Angular modules.When passed two or more arguments, a new module is created. If passed only one argument, an existing module (the name passed as the first argument to module) is retrieved。

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

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

// true,都是同一个模块
alert(createModule == getModule);
// Create a new module
var myModule = angular.module(‘myModule‘, []);

// register a new service
myModule.value(‘appName‘, ‘MyCoolApp‘);

// configure existing services inside initialization blocks.
myModule.config([‘$locationProvider‘, function($locationProvider) {
  // Configure existing providers
  $locationProvider.hashPrefix(‘!‘);
}]);

可参考:

http://www.mamicode.com/info-detail-247448.html

http://docs.angularjs.cn/api/ng/function/angular.module

 

angular.module

原文:http://www.cnblogs.com/simonbaker/p/5220840.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!