Tuesday, September 13, 2016

AngularJS - if you are calling a function from outside of Angular / scope , always do it inside of $apply()

Otherwise, it will silently fail.

So , this is ok:


function get_ang_scope(){



    var appElement = document.querySelector('[ng-app=kalaApp]');
    var $scope = angular.element(appElement).scope();

    return $scope;

}


var scope=get_ang_scope();

scope.$apply(function () {
//    scope.updateCustomRequest(data, type, res);
    scope.kd_gui_buttons_changegroup(val);

});


No comments:

Post a Comment

Ubuntu 12.04, 14.04, 16.04 - auto start an app or script before login

To run a command or application at startup, even before the user has logged in, you can use this file: /etc/rc.local The commands entered...