Jens Rantil's blog

Posted Fre 24 Maj 2013

AngularJS events on initialization

In my previous post I was giving an example of using AngularJS events.

I stumbled across a corner case that might be worth noting; If a service is triggering an event on initialization, no controllers will get notified of it. Here's an example:

The reason why this is happening is simply because the controller have not been instantiated. Setting a timer before emitting the event can be done as a workaround:

Now you know!

Category: misc
Tags: AngularJS JavaScript
Dude, did you like this blog post? Feel free to drop me some bitcoins at 1Q79HGDF3ZjfCwXLAW6e7gX4DeDu2GtZ7v.

Comments