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. 【java开发系列】— JDOM创建、改动、删除、读取XML文件

    有非常多中操作XML文件的方法,这里介绍一下JDOM的用法和技巧. JDOM下载地址 创建XML文档 XML文件是一种典型的树形文件,每一个文档元素都是一个document元素的子节点. 而每一个子元 ...

  2. case when遇到空串转成0

    须要注意:假设字段为varchar类型,when后的条件要加上引號 SELECT (CASE marital_status WHEN 0 THEN '已婚' WHEN 1 THEN '未婚' ELSE ...

  3. constraint使用方法总结

    主要就是添加约束的 下面几种约束 .并 一一列举: 1.主键约束: 要对一个列加主键约束的话,这列就必需要满足的条件就是分空 由于主键约束:就是对一个列进行了约束,约束为(非空.不反复) 下面是代码  ...

  4. Bootstrap 教程

    Bootstrap,来自 Twitter,是基于 HTML.CSS.JAVASCRIPT 的简介灵活的流行前段框架及交互组件集. 内容列表 Bootstrap 教程 Bootstrap 教程 Boot ...

  5. TP函数

    U方法用于完成对URL地址的组装,特点在于可以自动根据当前的URL模式和设置生成对应的URL地址,格式为:U('地址','参数','伪静态','是否跳转','显示域名');在模板中使用U方法而不是固定 ...

  6. [AngularJS] TweenList 3D + AngularJS Animate

    AngularJS animations and TweenLite make it really easy to create cool 3d effects in your application ...

  7. [CodeEdit--Sublime]一些好用的Plugins

    Sublime Text 3 Plugins (**)packet control:plugin包管理器 (**)netuts-fetch: (**)markdown editing:Markdown ...

  8. OS X 10.9 Mavericks 安装 thrift 0.9.1

    通过Homebrew安装的时候,编译会报错.查了一下资料,原来是10.9系统默认使用的libc++的库,而且移除了C++ 11标准前tr库,所以编译存在问题.且笔者使用的时候,brew安装只支持到0. ...

  9. 基于HTML5 SVG炫酷文字爆炸特效

    这是一款使用html5 svg.css3和js制作的炫酷文字爆炸特效.该文字特效用SVG path属性将文字路径切割为很多小块,然后使用css3和js在鼠标滑过文字时制作文字爆炸分裂的炫酷效果. 在线 ...

  10. shell 笔记

    shell 笔记 通配符 没有 '.' [Aa] 表示 A 或者 a ? 表示任意字符 * 表示任意字符串 IFS data='name, sex, rollno, location' oldIFS= ...