2014-11-15 94 views
1

我創建我的評級angularJS定製指令執行JavaScript。我想在加載html模板後運行javascript。那我該怎麼做?後指令模板已經加載

我的代碼:

app.directive('ratingControl',function(){ 
    return { 
     restrict:'EA', 
     templateUrl:'rating.htm', 
     link :function(scope,element,attr) {} 
    }; 
}); 
+0

後期使用功能... –

+0

@ user1760979如何使用後的功能。請詳細解釋 –

+1

你可以簡單地把你的JavaScript變成鏈接方法。 –

回答

3

使用$timeout功能鏈接:在鏈接

// You might need this timeout to be sure it runs after DOM render. 
$timeout(function() { 
    //your code 
}, 0,false); 
+2

我把這個放在哪裏? –

+0

是的,我想放哪裏? –