![](/img/trans.png)
[英]Angular directive to execute a function after HTML element has been loaded
[英]Execute Javascript after directive template has been loaded
我在angularJS中创建了自定义指令以进行评级。 我想在加载html模板后运行javascript。 那我该怎么做呢?
我的代码:
app.directive('ratingControl',function(){
return {
restrict:'EA',
templateUrl:'rating.htm',
link :function(scope,element,attr) {}
};
});
在链接中使用$timeout
函数:
// You might need this timeout to be sure it runs after DOM render.
$timeout(function () {
//your code
}, 0,false);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.