PoliticalFraming / politicalframing

http://www.politicalframing.com
9 stars 1 forks source link

AnalysisViewer weird hack for broadcasting event #37

Closed AlJohri closed 10 years ago

AlJohri commented 10 years ago

Not sure why I need a setTimeout in order to broadcast this event. I'd like to broadcast the event as soon as the controller gets initialized.

  setTimeout(function() {
    $scope.$broadcast('graphRequested');
    console.log("event emitted??");
  }, 15);
AlJohri commented 10 years ago

Also it totally doesn't work the first time its clicked -- perhaps because of the 15 millisecond delay? Bumping this up to MVP-2 mileston.

AlJohri commented 10 years ago

It also doesn't work when directly accessing a particular analysis.

AlJohri commented 10 years ago

The ideal solution would be to use something like

$scope.$on('graphRequested', function(event, args) {
   //...
});

but the directive isn't loaded fast enough in order to receive the 'graphRequested' event.

$scope.$watch("current.filters.id", function(newValue, oldValue) {
   //...
});

This solution above works for now.