[AngularJS] Exploring the Angular 1.5 .component() method
Angular The angularjs Component 1.5 method Exploring
2023-09-14 08:59:20 时间
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
相关文章
- Angular 结合 dygraphs 实现 annotation
- Angular和Vue.js 深度对比
- 前端必读3.0:如何在 Angular 中使用SpreadJS实现导入和导出 Excel 文件
- 关于 SAP Spartacus Angular HTTP Interceptor 的拦截顺序
- angular基础面试题_java web面试题
- angular 路由懒加载_angular路由
- Angular 应用里 index.html 的作用
- 使用 Angular Universal 进行服务器端渲染的防御性编程思路
- Angular Universal Application 应该处理 HTTP POST 请求吗?
- Angular 应用开发里使用 ForRoot 解决 Lazy Loaded Module 里单例行为丢失的问题
- 【Angular教程】自定义管道
- Angular forRoot 方法的使用场合介绍
- Angular 应用里 ng-package.json 文件的作用是什么?
- Angular 依赖注入错误消息:ERROR Error NullInjectorError No provider for XX
- Angular 应用里 server.ts 文件的 APP_BASE_HREF token 的用法?
- ORA-28074: The “string” field of the redaction parameters is not valid. ORACLE 报错 故障修复 远程处理
- ORA-28077: The attribute specified (string) exceeds the maximum length. ORACLE 报错 故障修复 远程处理
- ORA-38475: The attribute set and the associated ADT are out of sync. ORACLE 报错 故障修复 远程处理
- ORA-48485: The file exceeds the maximum length [string] ORACLE 报错 故障修复 远程处理
- ORA-48490: The field number exceeds the maximum number [string] ORACLE 报错 故障修复 远程处理
- ORA-53035: The rows for the mapping document (string) do not exist. ORACLE 报错 故障修复 远程处理
- ORA-55568: The maximum query length (mql) value should be atmost string based on the current _highthreshold_undoretention setting. ORACLE 报错 故障修复 远程处理
- ORA-01378: The logical block size (string) of file string is not compatible with the disk sector size (media sector size is string and host sector size is string) ORACLE 报错 故障修复 远程处理
- ORA-13703: The snapshot pair [string, string] for database_id string and instance_id string are not found in the current repository. ORACLE 报错 故障修复 远程处理
- Angular 4.0发布,致力于减小代码体积详解编程语言
- Exploring the Power of MongoDB: The Definitive Guide to Upgrading Arrays(mongodb更新数组)