整理 Anglarjs的service,directve的基本用法
来源:互联网 发布:游族网络官网个人中心 编辑:程序博客网 时间:2024/06/04 03:41
service,Service就是【单例对象】在AngluarJS中的一个别名,保证你每次访问到都是一个实例。
EX:
module.service(‘book’,[‘$scope’,function($rootscope)
{
var service={book:[
{title:”Mag”,author:”Raynd”},
{title:”Thos”,author:”cone”}
],
addBook:function(book){
service.books.push(book);
$rootScope.$broadcast(‘books.update’);
}
}
Return service;
}]);
index
index: index 属性可返回下拉列表中选项的索引位置。
DIRECTIVES(指令)
EX:
Module.directive(“abbbookbutton”,[‘Book’,function(Book)
{
Return{
Restrict:”A”,
Link:function(scope,elements,attrs){
Element.bind(“click”,function(){
Book.addBook({title:”StarWars”,author:”wwww”});
});
}
}
]);
把该指令应用到视图中
<buttonadd-book-button>add book</button>
DIRECTIVE主要作用是
Un-DRY
Angularjs 链接
http://angularjs.cn/A0kK
- 整理 Anglarjs的service,directve的基本用法
- AnglarJs的一些笔记
- Service的基本用法
- Service的基本用法
- Service的基本用法
- Service的基本的用法
- Android Service的基本用法
- Service服务的基本用法
- 服务Service的基本用法
- 整理sar的基本用法
- 登录的anglarJS使用,简单易懂
- Android下的Service的基本用法
- Android Service 服务的基本用法
- service的基本用法+远程服务
- android---(Service服务的基本用法)
- Android Service的基本用法(1)
- sizeof的基本用法的整理
- auto_ptr基本用法和实现的整理
- Divide Groups
- Extjs textfield 宽
- java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy
- POJ 3253 Fence Repair (优先队列)
- 人证比对TCPSERVER
- 整理 Anglarjs的service,directve的基本用法
- Tabbar与Navigation嵌套
- 《C++Primer 5th》 读书笔记2--const
- Eclipse的安装
- iptable
- Sprite 3D用法和相关特性详解(包括如何从零到一个完整工程)
- vim菜单栏修改成英文的方法
- Holding Bin-Laden Captive!
- vim基本命令