Coming from $state.go(...) (https://github.com/angular-ui/ui-router), $locationChangeSuccess is called AFTER controller are initialized and views are loaded. This causes a small problem displaying messages.
Scenario:
I call $state.go('newState') and controller A gets initialized.
controller A has a method init() which will call messageCenterService.add('info', 'Message', options);
AFTER this, angular will now broadcast $locationChangeSuccess and the following happens:
// Update 'unseen' messages to be marked as 'shown'.
messageCenterService.markShown();
// Remove the messages that have been shown.
messageCenterService.removeShown();
(https://github.com/e0ipso/message-center/blob/master/message-center.js lines 125-132)
Because the newly created info-message is in an 'unseen' state, it will be marked as 'shown' and removed. Due to this, after everything is loaded, user can't see the message.
Workaround for this is to also listen to $locationChangeSuccess in controller A and recall the message.
$rootScope.$on('$locationChangeSuccess', function locationChanged(event, to) {
showMessage();
});
But this needs a better solution, not a hack.
Coming from $state.go(...) (https://github.com/angular-ui/ui-router), $locationChangeSuccess is called AFTER controller are initialized and views are loaded. This causes a small problem displaying messages.
Scenario:
I call
$state.go('newState')and controller A gets initialized.controller A has a method
init()which will callmessageCenterService.add('info', 'Message', options);AFTER this, angular will now broadcast $locationChangeSuccess and the following happens:
(https://github.com/e0ipso/message-center/blob/master/message-center.js lines 125-132)
Because the newly created info-message is in an 'unseen' state, it will be marked as 'shown' and removed. Due to this, after everything is loaded, user can't see the message.
Workaround for this is to also listen to $locationChangeSuccess in controller A and recall the message.
But this needs a better solution, not a hack.