opengl opengl - 2 years ago 92
AngularJS Question

AngularJS change variable with console

I'm learning Angular and I made a simple game, I'm using ng-inspector to view current variable value, but how can I cahange variable value with browser console?

Answer Source

You can get $scope from jquery/jqlite selector like desribed here, see function scope(). Change model attached to $scope and call $apply on this scope.

So the full script will be:

var $scope = $(#game-result-score-value).scope();
$scope.$apply(function () { $scope.score = 1;  });
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download