I 've just started to study Angular. Consider the following simple template:
<div ng-app ng-init="qty=1;cost=2">
<div>
Quantity: <input id="quantity" type="number" min="0" data-ng-model="qty">
</div>
<div>
Costs: <input type="number" min="0" data-ng-model="cost">
</div>
<div>
Total: {{qty * cost | currency}}
</div>
</div>
I 've tried the following in Chrome's console:
var $scope = angular.element($('#quantity')).scope();
$scope.qty; //1
By changing the first input text from 1 to 3 manually, I am getting:
$scope.qty; //3
So far, so good! First question: Why the opposite does not work? Namely,by setting $scope.qty=5; input text does not change.
Second question: By applying e.g. $('#quantity').val(12); the input text changes, however the expression in Total is not recalculated and DOM is not refreshed!