AngularJS 学习笔记---Module
What is a Module?You can think of a module as a container for the different parts of your app – controllers,services,filters,directives,etc. Why?Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach:
The BasicsI'm in a hurry. How do I get a Hello World module working? <div ng-app="myApp"> <div> {{ 'World' | greet }} </div> </div> // declare a module var myAppModule = angular.module('myApp',[]); // configure the module. // in this example we will create a greeting filter myAppModule.filter('greet',function() { return function(name) { return 'Hello,' + name + '!'; }; }); it('should add Hello to the name',function() { expect(element(by.binding("'World' | greet")).getText()).toEqual('Hello,World!'); }); Important things to notice:
Recommended SetupWhile the example above is simple,it will not scale to large applications. Instead we recommend that you break your application to multiple modules like this:
You can find a community The above is a suggestion. Tailor it to your needs. The Passing one argument retrieves an existing ModuleA module is a collection of services,controllers,and configuration information. // 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('!'); }]); Then you can create an injector and load your modules like this: var injector = angular.injector(['ng','myModule']) However it's more likely that you'll just usengAppor Usage
Arguments
Returns
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 一些常用的WebServices 天气,IP,邮编,Email,火车时刻表
- scala – 在O(1)中是否有一个带有Peek()的有界队列的纯函数
- angularjs – 如何使用angular-ui-router将路由配置拆分为多
- WebService之Soap协议数据解析篇
- WebService入门篇
- gsoap webservice weatherservice
- controller – AngularJS – 按ID获取数据
- java-从Maven Sonatype Nexus存储库下载私有jar的Docker自动
- Linux 下mysql通过存储过程实现批量生成记录
- 数组 – 如何在Scala中有效地将数组复制到另一个数组?