javascript - AngularJS: Model not updating in controller scope -
i have following controller:
app.controller('myctrl', function($interval, $scope) { $scope.foo = 2; $interval(function() { console.log($scope.foo); }, 1000); }); and following code in view:
<input type="text" ng-model="foo" /> when load page, input correctly populated value "2". however, if change value in input, console continues log "2" (without quotes).
i've used $interval illustrate - $watch() callback fires once , never again. if use ng-change="" on input, $scope.foo in callback equal 2.
what doing wrong?
if use ng-model, have have dot in there .
bind model creating object
controller
$scope.form={ foo:0 }; view
<input type="text" ng-model="form.foo" />
Comments
Post a Comment