ViewContentLoaded or document.ready() in Custom directive

6,678 views
Skip to first unread message

Abdul Azeez Shaik

unread,
Aug 19, 2012, 5:17:23 PM8/19/12
to ang...@googlegroups.com
Hi,

I have a custom directive whose is using standard 'ng-repeat' and other angular directives. 
However, i need to call a jquery function on the custom directive element after the content is loaded.

In postlink function, template is getting loaded but 'ng-repeat' elements are yet to get executed.
Is there any other function/ event where i need to call the jQuery function. (function which i would call normally in $document.ready() ).

Thanks,
 Abdul

Abdul Azeez Shaik

unread,
Aug 20, 2012, 4:12:32 AM8/20/12
to ang...@googlegroups.com
Shouldn't elements in ng-repeat must also be rendered by the time postLink function executed?
When would all ng-repeat elements of directive get renendered?
Any pointers to resolve this?

Couldn't find this in documentation.

Roy Choo

unread,
Aug 20, 2012, 10:00:41 PM8/20/12
to ang...@googlegroups.com
Hi,

you could have another directives to check if the last element is ready.
see this for example.

http://jsfiddle.net/roychoo/XVzUW/3/

Regards
Roy

Abdul Azeez Shaik

unread,
Aug 21, 2012, 5:03:31 AM8/21/12
to ang...@googlegroups.com
Hi Roy,

Thanks for the reply. I tried this in my app and Its working great. 
Also, got to know the other way of implementing this from, just posting here so that it might be of some help to starters like me, http://stackoverflow.com/questions/12021152/jquery-calls-not-working-in-viewcontentloaded-of-angular

Thanks once again for giving this solution.

Regards,
Abdul

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.
 
 

Reply all
Reply to author
Forward
0 new messages