Decorate $onInit method of component in 1.5 for common functionality

25 views
Skip to first unread message

J Java

unread,
Dec 2, 2017, 1:33:44 PM12/2/17
to Angular and AngularJS discussion
I would like to have a decorator for $onInit of components to execute common functionality. Something like preInit postInit applicable to all components (or optionally selective components) I came up with some thing like this : https://jsbin.com/vevexik/1/edit?html,js
any thought if above is best way to go or any suggestions?
I have raised this on https://stackoverflow.com/questions/47604461/way-to-decorate-angular-1-5-oninit-component-for-common-functionality as well

Sander Elias

unread,
Dec 4, 2017, 1:53:06 PM12/4/17
to Angular and AngularJS discussion
Hi J,

As far as I can see you are not decorating anything, but you are using the $onInit as intended, so I don't see a problem.

Regards
Sander

J Java

unread,
Dec 5, 2017, 2:01:01 AM12/5/17
to ang...@googlegroups.com
Hi Sanders,

Not sure why it is not decorating $controller and $onInit as well?
$controller is decorated using $decorator itself and adds a functionality (by calling modal device method) before  and after $onInit on the controller is called without injecting anything in individual controller. 

Regards,
Shailesh.

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages