I've got a component with a $postLink hook defined, in which it $broadcast 
a event, something like this:

.component('mycmp',{
  controller: function($scope) {
    var mydata = {};
    // some logic with mydata
    this.$postLink = function(){
      $scope.$broadcast('myevent', mydata); //I want to test this event, to 
make sure it's fired with the right data
    }
  }
})

Since the $scope (isolated) is created at compilation time and I don't know 
how to spy on it in advance, before I can grab the isolateScope, the event 
is already fired.

var scope = $rootScope.$new();
var element = $compile('<mycmp></mycmp>')(scope);
var isolateScope = element.isolateScope();
spyOn(isolateScope, '$broadcast'); //this is too late, the event has 
already been fired when $compile is called.

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 angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to