1

I have created my custom directive for rating in angularJS. I want to run javascript after loading of html template. So how can i do that?

my code:

 app.directive('ratingControl',function(){
     return {
         restrict:'EA',
         templateUrl:'rating.htm',
         link :function(scope,element,attr) {}
     };
 });
3
  • use post function in link... Commented Nov 15, 2014 at 11:36
  • @user1760979 how to use post function. Please explain in detail Commented Nov 15, 2014 at 11:38
  • 1
    You can simply put your JavaScript into link method. Commented Nov 15, 2014 at 11:53

1 Answer 1

3

Use $timeout function in link:

// You might need this timeout to be sure it runs after DOM render.
$timeout(function () {
    //your code
}, 0,false); 
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, where I suppose to put?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.