2

i m using ui router for state management. i have some directives that are behaving as listeners of some events

  app.directive('signer', ['Constant', "GlobalService", 
    function (constant, globalService) {
     return {
            restrict: "A",
            scope: {},
  link: function (scope, element) {
var workflowLoaded;
 workflowLoaded = scope.$on('event:workflowLoaded', function (data) {
                globalService.performAction();
            });

scope.$on('$destroy', function () {                
                if (workflowLoaded) workflowLoaded();               
            });
  }
      }
    }]);

Scenario : user navigating from one view to other view that contains Signer directive which reloads the directive

Issue: when item.html loads it register for event, but as $destory called after $statechangesuccess it de-register the event.

how to resolve the issue, any help will be appreciated

they have discussed it here but i cant find the solution https://github.com/angular-ui/ui-router/issues/2485

Salman
  • 1,266
  • 5
  • 21
  • 41
  • The directive is destroyed when the view is changed along with its listeners. What are you trying to achieve? – Muli Yulzary Jul 13 '16 at 14:42
  • its was expected that directive destroy will be called before state change . but in reality its not happening .i m unregister events on destroy – Salman Jul 13 '16 at 14:44
  • That is redundant code. check this: http://stackoverflow.com/a/27016855/2652883 – Muli Yulzary Jul 13 '16 at 14:46
  • That is not redundant code as next UI view holds same html and its required with newer values . https://github.com/angular-ui/ui-router/issues/2485 – Salman Jul 14 '16 at 05:30

0 Answers0