Thanks so much. I will try to use that for best practices.
But i am from an outsource industry, the customer they are familiar with
publish/subscribe patterns. They want to communicate between controllers
via *events*
ParentController - subscribe '*ctr1Submitted*' -> publish '*ctrl1Updated*'
Controller-1 - fire event '*ctrl1Submitted*', ctrl1.data
Controller-2 - subscribe '*ctrl1Updated*' to update data
This flow is work well with create mode. But in edit mode, We already has
data, the customer want to fire events in *ParentController*
ParentController($scope, data) {
$scope.$broadcast('*ctrl1Updated*', data)
}
unfortunately the Controller-2 is not initialized yet to subscribe this
event, I try to use
$timeout(function() {
$scope.$broadcast('*ctrl1Updated*', data)
}) ;
It works well, but the customer is afraid of $timeout sometimes does not
work.
Just want to know and learn more about that problems. Using Service is
great, but in my situation I need to make sure about events. Please share
your idea here. Thanks !
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.