controller,link,compile不同
2016-02-19 10:06
260 查看
测试案例
controller先运行,compile后运行,link不运行
将上例中的compile注释掉,controller先运行,link后运行,link和compile不兼容
.directive('testDirective', function() { return { restrict: 'E', template: '<p>Hello {{number}}!</p>', controller: function($scope, $element){ $scope.number = "controller:"+$scope.number; }, link: function(scope, el, attr) { scope.number = "link:"+scope.number; }, compile: function(element, attributes) { return { pre: function preLink(scope, element, attributes) { scope.number = "compile: pre:"+scope.number; }, post: function postLink(scope, element, attributes) { scope.number = "compile: post:"+scope.number; } }; } } });
controller先运行,compile后运行,link不运行
将上例中的compile注释掉,controller先运行,link后运行,link和compile不兼容
相关文章推荐
- JS实现精确加减乘除
- 七天学会ASP.NET MVC (一)——深入理解ASP.NET MVC
- 常用LINUX命令
- [网络流24题] 最小路径覆盖问题
- android的四大组件
- C与C++中使用带默认值的参数
- PHP编程中10个最常见的错误
- SQL中distinct与order by联合使用应该注意的问题
- 编译安卓源码
- 程序员的安全感
- 性能测试之Tomcat优化
- 同事在课堂上分享的正则表达式(转载)
- 日日日日
- BusyBox下ftpget的使用方法
- (22)odoo 安装旧模块报错处理
- VLAN间路由之单臂路由
- java中有用小函数收集
- 对比分析php中Cookie与Session的异同
- 浅谈负载均衡器LVS
- Spring Bean的生命周期