[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 ...
随机推荐
- 一、初识T4引擎
对于代码生成器我们并不陌生,在日常编码中这也是用的比较多的工具之一.一般代码生成器主要功能是生成公共或基础代码来减少编码人员的工作量,而一款优秀的代码生成器除了生产代码以外,同时兼具生成项目架构和基础 ...
- NPM环境搭建
1. NPM全局路径:配置npm包的安装位置,在你的用户文件夹下,新建.npmrc文件:cache=D:\NodeJs\nvm\npm-cache 表示缓存文件夹 prefix=D:\NodeJs\n ...
- 关于T-SQL重编译那点事,内联函数和表值函数在编译生成执行计划的区别
本文出处:http://www.cnblogs.com/wy123/p/6266724.html 最近在学习 WITH RECOMPILE和OPTION(RECOMPILE)在重编译上的区别的时候,无 ...
- 30.SSH配置文件模板.md
[toc] 1.struts2 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts ...
- 一种实现C++反射功能的想法(一)
Java的反射机制很酷, 只需知道类的名字就能够加载调用. 这个功能很实用, 想象一下, 用户只需指定类的名称, 就可以动态绑定类型, 而且只需通过字符串指定, 字符串的使用可以使得用户的修改只需修改 ...
- Qt之QCustomPlot绘图(一)配置和第一个例子
最近一个用Qt开发的项目需要绘制坐标曲线,我在老师的指点下使用了QCustomPlot这个插件,使用方法简单,功能还算不错. 可是在网上找了很多资料和博文都只是将官方提供的例子演示一遍,没有系统全面的 ...
- nuc900 nand flash mtd 驱动
nuc900 nand flash mtd 驱动,请参考! /* * Copyright © 2009 Nuvoton technology corporation. * * Wan ZongShun ...
- javascript 中的nextSibling和previousSibling使用注意事项
JavaScript中的nextSibling和previousSibling和作用类似于jquery的next()和prev(),都是获取下一个/上一个同胞元素,如果下一个同级节点不存在,则此属性返 ...
- Jquery中$.post()与$.get()区别
1:GET访问 浏览器 认为 是等幂的 就是 一个相同的URL 只有一个结果[相同是指 整个URL字符串完全匹配] 所以 第二次访问的时候 如果 URL字符串没变化 浏览器是 直接拿出了第一次访问的结 ...
- CentOS 5.6服务器配置YUM安装Apache+php+Mysql+phpmyadmin
1. 更新系统内核到最新. [root@linuxfei ~]#yum -y update 系统更新后,如果yum安装时提示错误信息,请执行以下命令修复. [root@linuxfei ~]#rpm ...