javascript - trigger resize event causes error $digest already in progress angularjs -


i'm trying set resize active on angualr js directive cause dygraph begin scope.option.eidth = 0 if set value.. after many tries found this:

window.dispatchevent(new event('resize')); 

and in browser works ! if put no directive raises error

angular.js:11655 error: [$rootscope:inprog] $digest in progress http://errors.angularjs.org/1.3.15/$rootscope/inprog?p0=%24digest 

i know caused scope state in digest instead of apply.. there way verify this?

my code:

(function() {     var app = angular.module('dashboard.view', []);      app.directive('dygraph', function(){         return {             restrict: 'e',             scope: {                 data    : '=',                 options : '=?'             },             template: '<div id="graphdiv" style="width: 100%"></div>',             link: function (scope, elem, attrs) {                 var div = elem.children()[0];                 scope.options.width = elem.parent()[0];                  console.log("scope.$$phase ",scope.$$phase);                 var graph = new dygraph(div, scope.data, scope.options);                 if(scope.options.title=="scanning" || scope.options.title=="bytes" || scope.options.title=="pakets"){                      graph.ready(function(){                          if(scope.$$phase!='$diggest'){                             window.dispatchevent(new event('resize'));                         }                     });                      console.log("scope.options.width 2",scope.options.width);                 }              }                 };     });  })(); 


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -