angular学习笔记-1

2014-09-29

Angular

个人理解,angular是一个MVC模板库,将页面在浏览器端组装。

因为是笔记,所以只是记录我的想法,别人可能看不懂。

关于angular的兼容性,1.2版以后就不支持ie8以下了,用网上写的方法也不行,网上的兼容ie8以下的方法应该是1.1.5版本以下可以。

ng-app指明了angular的html作用域。

usage
example1: example2:
<!Doctype html>
<html ng-app="MyApp">
<head>
</head>
<body>
<div class="test"></div>
</body>
</html>
angular的引导程序作用域在整个html中。
<!Doctype html>
<html>
<head>
</head>
<body>
<div class="test" ng-app="MyApp"></div>
</body>
</html>
angular的引导程序作用域在class="test"的div中。

模块化写法:

html结构参照上面的表格:

module:
var appModule = angular.module('MyApp',[]);
/* angular.module第1个参数是模块的名称(指明根节点),即ng-app的命名,第2个数组参数是指明依赖的模块,还有第3个参数,是一个function,定义初始化函数 */

appModule.controller("controllerName",function);

appModule.service('serviceName',[]);
comments powered by Disqus