[AngularJS] Exploring the Angular 1.5 .component() method
Angualr 1.4:
.directive('counter', function counter() {
return {
scope: {},
restrict: 'EA',
transclude: true,
bindToController: {
count: '='
},
controller: function () {
function increment() {
this.count++;
}
function decrement() {
this.count--;
}
this.increment = increment;
this.decrement = decrement;
},
controllerAs: 'counter',
template: [
'<div class="todo">',
'<input type="text" ng-model="counter.count">',
'<button type="button" ng-click="counter.decrement();">-</button>',
'<button type="button" ng-click="counter.increment();">+</button>',
'</div>'
].join('')
};
});
Angualr1.5:
.compoment('counter', {
bindings: {
count: '='
},
controller: function () {
function increment() {
this.count++;
}
function decrement() {
this.count--;
}
this.increment = increment;
this.decrement = decrement;
},
controllerAs: 'vm',
template: function($element, $attrs){
return [
'<div class="todo">',
'<input type="text" ng-model="vm.count">',
'<button type="button" ng-click="vm.decrement();">-</button>',
'<button type="button" ng-click="vm.increment();">+</button>',
'</div>'
].join('');
},
// restrict: 'E',
// transclude: true
});
- Direcitve need pass in function, compoment need pass in object.
- 'scope' and 'bindToController' can be replaced with just 'bindings'
- by default restrict: 'E'
- by default transclude: true
- by default, if not given controllerAs, angular will create for you and name is the same as compoment name
[AngularJS] Exploring the Angular 1.5 .component() method的更多相关文章
- Exploring the Angular 1.5 .component() method
Angular 1.5 introduced the .component() helper method, which is much simpler than the.directive() de ...
- [Angular] Use Angular components in AngularJS applications with Angular Elements
When migrating AngularJS (v1.x) applications to Angular you have different options. Using Angular El ...
- AngularJs学习笔记--Understanding the Model Component
原版地址:http://docs.angularjs.org/guide/dev_guide.mvc.understanding_model 在angular文档讨论的上下文中,术语“model”可以 ...
- AngularJs学习笔记--Understanding the Controller Component
原版地址:http://docs.angularjs.org/guide/dev_guide.mvc.understanding_model 在angular中,controller是一个javasc ...
- 【js类库AngularJs】解决angular+springmvc的post提交问题
[js类库AngularJs]解决angular+springmvc的post提交问题 AngularJS诞生于2009年,由Misko Hevery 等人创建,后为Google所收购.是一款优秀的前 ...
- [AngularJS] Using the Angular scope $destroy event and method
With Angular scopes, you have access to a $destroy event that can be used to watch $scope events. Th ...
- [AngularJS] Test an Angular Component with $componentController
Traditionally you had to create DOM elements to test a directive but by shifting our focus to compon ...
- [AngularJS] Lazy loading Angular modules with ocLazyLoad
With the ocLazyLoad you can load AngularJS modules on demand. This is very handy for runtime loading ...
- [AngularJS] New in Angular 1.3 - Performance Boost with debugInfoEnabled
By default, Angular provides a lot of debug information on the DOM that's only necessary for tools l ...
随机推荐
- Android LayoutInflater和findViewById 源码详解
LayoutInflater大家很熟悉,简单点说就是布局文件XML解析器,setContentView函数也是调用了LayoutInflater 用法: View view = LayoutInfla ...
- c#字符串驻留机制
http://www.cnblogs.com/instance/archive/2011/05/24/2056091.html
- 简单总结焦点事件、Event事件对象、冒泡事件
每学习一些新的东西,要学会复习,总结和记录. 今天来简单总结一下学到的几个事件:焦点事件.Event事件对象.冒泡事件 其实这几个事件应该往深的说是挺难的,但今天主要是以一个小菜的角度去尝试理解一些基 ...
- java_reflect_04
反射操作数组: 通过public Class<?> getComponentType()来取得一个数组的Class对象 例: import java.lang.reflect.Array ...
- MySQL索引及Explain及常见优化
MySQL索引设计的原则 1. 搜索的索引列,不一定是所要选择的列.换句话说,最适合索引的列是出现在WHERE 子句中的列,或连接子句中指定的列,而不是出现在SELECT 关键字后的选择列表中的列. ...
- Spring mvc 中有关 Shiro 1.2.3 配置问题
Spring 版本:3.2.x, 4.0.x [问题说明] 首先介绍下配置出错情况: (1)项目中,Spring3 and Spring4 的 applicationContext.xml aop ...
- dota监测
漫漫长假一个人无聊得很,整日DOTA,打的腰酸背痛腿抽筋的.就想着写一个脚本记录自己每天打游戏的时间,于是就产生了下面的这个东西... 运行环境:win7 32位. python版本:3.4.1 由于 ...
- php图片上传
//处理图片 private function imageDeal($param){ $arrType=array('image/jpg','image/bmp','image/png','image ...
- ecshop里Ajax.call()方法定义
Ajax.call()在哪个文件中定义的? 在加载的js/transport.js文件里面. Ajax.cal()方法就是Transport.run()方法
- PHP文件类型检查类-比较全的
在CSDN上淘来的一个文件类型的类,还不错,留下自己看! <? /** * 检证文件类型类 * * @author */ class FileTypeValidation { // 文件类型,不 ...