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 : ...
随机推荐
- ASSER、VERIFY、TRACE详解
ASSERT()被测试它的参数,如果参数为零,则中断执行并打印一段说明消息.在Release版本的程序中它不起任何作用. ASSERT()使用的时候必须保证参数表达式中不能有函数调用,因此对于任何有函 ...
- 远程调用WMI安装软件
Invoke-WMIMethod -ComputerName $ip -Credential $cred -path Win32_product -Name Install -ArgumentLi ...
- js原生appendChild的bug
appendChild 主要是用来追加节点 插入到最后 window.onload = function(){ var ul2 = document.getElementById('ul2'); va ...
- C#操作Excel(1)Excel对象模型
Excel对象模型 (.Net Perspective) 本文主要针对在Visual Studio中使用C# 开发关于Excel的应用程序 本文的PDF下载地址:C#操作Excel2007.pdf ...
- vs 设置生成的实体为复数
- Java Web模块——验证码模块
一.什么是验证码及它的作用 验 证码为全自动区分计算机和人类的图灵测试的缩写,是一种区分用户是计算机的公共全自动程序,这个问题可以由计算机生成并评判,但是必须只有人类才能解答. 可以防止恶意破解密码. ...
- 各种ORM安装
1.EF安装 2.PetaPoco安装 Install-Package PetaPoco 3.
- DropDownList的多级联动
DropDownList的多级联动的问题最典型的案例就是实现省市级三级联动的案例,对这个问题的描述是当选中山东省之后,在选择市的下拉菜单时,市一栏只出现山东省下面的市.对于县也是同样的道理. 我也做的 ...
- scala命令
1. intersect方法找出两个字符串的相同字符: scala> "Hello".intersect("World") res3: String = ...
- APP快速通过苹果AppStore审核九大诀窍
[IT168技术]对于移动应用开发者来说, 最令人沮丧的可能莫过于辛辛苦苦开发的应用, 没能通过苹果AppStore的审核,或者在应用更新时遭遇下架.苹果的AppStore的审核流程和标准, 一向不透 ...