How to manipulate or perform operation on data Inside Custom Directive ?

10 views
Skip to first unread message

Chaitanya Babar

unread,
Jul 17, 2017, 1:23:04 PM7/17/17
to Angular and AngularJS discussion
Hi All,

As we all know Directives are used for decorating the HTML , but if in case we need to have a scenario in which we have to ,manipulate or perform operation on data Inside Custom Directive . How should it be done from following ways or is it there any better way.

a. Inside Controller of directive (which i guess might me the right place)
b. Inside the post Link function

Can you please put in your thoughts & suggest me which should be used.

Thanks,
Chaitanya

Sander Elias

unread,
Jul 18, 2017, 5:47:41 AM7/18/17
to Angular and AngularJS discussion
Hi Chaitanya,

Yes, indeed, inside the directive's controller. Don't use any of the link functions, unless there is a real need for one of those.
I'm not entirely sure, but I think most of the life-cycle callbacks for components are also available on directives. Make use of those.

Regards
Sander

Chaitanya Babar

unread,
Jul 23, 2017, 4:43:58 AM7/23/17
to Angular and AngularJS discussion
Thanks Sander 
Reply all
Reply to author
Forward
0 new messages