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的更多相关文章

  1. [AngularJS] Lazy loading Angular modules with ocLazyLoad

    With the ocLazyLoad you can load AngularJS modules on demand. This is very handy for runtime loading ...

  2. Calling unknown method: app\modules\mobile\controllers\CompanyController::redirect()

    $this->redirect(['default/error']); Yii::$app->end();上边的代码出现 Calling unknown method: app\modul ...

  3. Angular概念纵览

    Conceptual Overview Template(模板): HTML with additional markup (就是增加了新的标记的HTML) Directive(指令): extend ...

  4. (七)理解angular中的module和injector,即依赖注入

    (七)理解angular中的module和injector,即依赖注入 时间:2014-10-10 01:16:54      阅读:63060      评论:1      收藏:0      [点 ...

  5. Angular JS中的依赖注入

    依赖注入DI angularjs中与DI相关有angular.module().angular.injector(). $injector.$provide. DI 容器3要素:服务的注册.依赖关系的 ...

  6. Angular源代码学习笔记-原创

    时间:2014年12月15日 14:15:10 /** * @license AngularJS v1.3.0-beta.15 * (c) 2010-2014 Google, Inc. http:// ...

  7. 理解angular中的module和injector,即依赖注入

    理解angular中的module和injector,即依赖注入 依赖注入(DI)的好处不再赘言,使用过spring框架的都知道.angularjs作为前台js框架,也提供了对DI的支持,这是java ...

  8. 转: angular编码风格指南

    After reading Google's AngularJS guidelines, I felt they were a little too incomplete and also guide ...

  9. 前端面试angular 常问问题总结

    1. angular的数据绑定采用什么机制?详述原理 angularjs的双向数据绑定,采用脏检查(dirty-checking)机制.ng只有在指定事件触发后,才进入 $digest cycle : ...

随机推荐

  1. CUDA Memories--CUDA记忆体(翻译+整理+测试)

    一边学习一边记录(本文中英结合,专业名词统统不翻译) 在CUDA里,host和devices有不同的记忆体空间. 首先呢,CUDA的memory有很多种类啦 1. Global memory 2. C ...

  2. matlab reshape函数

    语法 (1)B = reshape(A,m,n) 使用方法: B=reshape(A,m,n) 返回m*n矩阵B,它的元素是获得A的行宽度.假设A没有m*n元素,得到一个错误结果. 样例: <s ...

  3. windows 支持curl命令

    curl 是一般linux发行版中都带有的小工具,利用这个工具可以很方便的下载文件, 我一般使用这个工具来查看某个页面相应的HTTP头信息,在Windows系统中我们也一样可以使用这个工具,如果不需要 ...

  4. iOS开发——图层OC篇&Quartz 2D各种绘制实例

    Quartz 2D各种绘制实例 首先说一下,本篇文章只是介绍怎么使用Quartz 2D绘制一些常用的图像效果,关于Quartz和其他相关技术请查看笔者之前写的完整版(Quartz 2D详解) 一:画线 ...

  5. IOS文件存储小结

    转自:http://tyragain.lofter.com/post/84706_c1503 首选项设置存储 NSUserDefaults 以及通过它控制的SettingBundle  NSUserD ...

  6. 何查看Tomcat版本信息

    转自:http://dengjianqiang200.blog.163.com/blog/static/65811920094644354148/ 一般来说,在tomcat启动时就会有版本信息,如: ...

  7. Android实现XML解析技术

    转载:Android实现XML解析技术 本文介绍在Android平台中实现对XML的三种解析方式. XML在各种开发中都广泛应用,Android也不例外.作为承载数据的一个重要角色,如何读写XML成为 ...

  8. Apache的编译安装error: APR not found. Please read the documentation

    提示configure: error: APR not found. Please read the documentation. 经网上查阅资料才知道这是Apache的关联软件 在apr.apach ...

  9. Pandas系列教程——写在前面

    之前搜pandas资料,发现互联网上并没有成体系的pandas教程,于是乎突然有个爱迪页儿,打算自己把官网的文档加上自己用pandas的理解,写成一个系列的教程, 巩固自己,方便他人 接下来就干这件事 ...

  10. Hadoop从2.2.0到2.7

    Hadoop2.2.0 GA release 通用版本,Hadoop2.2.0就是一个通用版本 Hadoop2.2.0是从Hadoop1.1.0升级过来的,增加了以下特性: 1.增加了YARN: 2. ...