angularjs - Cannot modify $scope inside graph2d on click handler -


is using visjs angular? using struggling figure out how access , modify scope variables. specifically, inside handler (such on click) of visjs, can't seem change scope variables @ all. funnily, tried rootscope , doesn't work either? i've never had happen.

i've set sample codepen here - see inside on-click not able change either $scope or $rootscope

http://codepen.io/pliablepixels/pen/wwopmd

code fragment of click handler:

graph2d.on('click',function (prop) {      alert ("you clicked");      $scope.myname = "terminator";      $rootscope.rootmyname="footer";    }); 

it's figured out consider using $timeout service instead. $scope.$apply might fail when digest cycle in progress.

so inject $timeout , this:

$timeout(function() {     $scope.myname = "terminator";     $rootscope.rootmyname="footer"; }); 

this still same thing $scope.$apply in safe manner.


Comments