opengl opengl - 11 months ago 45
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?


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;  });