part 2 Angular modules and controllers
What is a module in AngularJS?
A module is a container for different parts of your application i.e controllers,services,directives,filters,etc.
You can think of a module as a Main() method in other types of applications.
How to create a module?
Use the angular object's module() method to create a module.
var myApp = angular.module("myModule",[]);//the first parameter specify the name of module,the second parameter specify the dependence for the module,here i just set an empty array.
What is a controller in angular?
In angular a controller is a JavaScript function. The job of the controller is to build a model for the view to display.
How to create a controller in angular?
var myController = function($scope){
$scope.message="AngularJS Tutorial";
};
How to register the controller with the module?
myApp.controller("myController",myController); // 1 way
myApp.controller("myController",function($scope){ // 2 way
$scope.message="AngularJS Tutorial";
});

In js file , we can add a reference with angular.js to has some code tip.(autocomplete some angular member.)
part 2 Angular modules and controllers的更多相关文章
- [AngularJS] Lazy loading Angular modules with ocLazyLoad
With the ocLazyLoad you can load AngularJS modules on demand. This is very handy for runtime loading ...
- Calling unknown method: app\modules\mobile\controllers\CompanyController::redirect()
$this->redirect(['default/error']); Yii::$app->end();上边的代码出现 Calling unknown method: app\modul ...
- Angular概念纵览
Conceptual Overview Template(模板): HTML with additional markup (就是增加了新的标记的HTML) Directive(指令): extend ...
- (七)理解angular中的module和injector,即依赖注入
(七)理解angular中的module和injector,即依赖注入 时间:2014-10-10 01:16:54 阅读:63060 评论:1 收藏:0 [点 ...
- Angular JS中的依赖注入
依赖注入DI angularjs中与DI相关有angular.module().angular.injector(). $injector.$provide. DI 容器3要素:服务的注册.依赖关系的 ...
- Angular源代码学习笔记-原创
时间:2014年12月15日 14:15:10 /** * @license AngularJS v1.3.0-beta.15 * (c) 2010-2014 Google, Inc. http:// ...
- 理解angular中的module和injector,即依赖注入
理解angular中的module和injector,即依赖注入 依赖注入(DI)的好处不再赘言,使用过spring框架的都知道.angularjs作为前台js框架,也提供了对DI的支持,这是java ...
- 转: angular编码风格指南
After reading Google's AngularJS guidelines, I felt they were a little too incomplete and also guide ...
- 前端面试angular 常问问题总结
1. angular的数据绑定采用什么机制?详述原理 angularjs的双向数据绑定,采用脏检查(dirty-checking)机制.ng只有在指定事件触发后,才进入 $digest cycle : ...
随机推荐
- 测试HAPROXY的文件分流办法
测试HAPROXY的文件分流办法 http://blog.chinaunix.net/uid-20553497-id-3054980.html http://blog.sina.com.cn/s/bl ...
- ssh 命令行通过私钥登录其它设备
ssh -i root(私钥文件) root@IP (被访问的服务器IP) 这里备份一下了
- thinkphp关联查询
$list=$model->table("$dName d ,$mName m,$cName c") ->field('d.*,m.title as musicTitl ...
- k-means聚类JAVA实例
<mahout in action>第六章. datafile/cluster/simple_k-means.txt数据集例如以下: 1 1 2 1 1 2 2 2 3 3 8 8 8 9 ...
- 財哥面京东dm的经历【帮財哥发的】
关于面京东,感触仅仅有一个,虐的快吐血了.首先说京东分四个板块,有京东商城.京东金融.京东刚收购的拍拍和海外事业部.我这个职位主要是在金融部数据组做数据挖掘和机器学习,还有推荐系统.面试是在周 ...
- pylons使用多个数据库(multiple DB)
最近做的工程要修改成两个数据库的,一个测试数据库, 一个线上数据库. 所以就要把原来的只有一个数据库的改成两个数据库. 第一步:修改development.ini # SQLAlchemy datab ...
- linux文档编辑
编辑某个文档: 可以直接编辑的如你有文档aa,可以用vi aa [注意:必须在AA所在的目录下]: 如果没有文档而且你又想编辑就可以直接编辑vi aa[名字你可以随便命名]; 也可以先建立一个文档to ...
- Trie 树 及Java实现
来源于英文“retrieval”. Trie树就是字符树,其核心思想就是空间换时间. 举个简单的例子. 给你100000个长度不超过10的单词.对于每一个单词,我们要判断他出没出现过,如果出现 ...
- 教程:如何减小iOS应用程序的大小?
本文译自:Reducing the size of my App Q: 怎样才能让我的程序安装包小一点,让程序的下载和安装更快速? A: 本文收集了一些减小程序安装包大小的相关技巧(当第一次下载和安装 ...
- __attribute__((unused))
在gcc手册中找到了有关的解释: unused:This attribute, attached to a function, means that the function is meant to ...