http://jsfiddle.net/ntszE/
<input type="text" placeholder="0" ng-model="deposit" value="4" />€
alert('begin test');
alert($scope.deposit);
alert('end test');
What am I doing wrong in binding the input value to a scope variable?
You have to access the $scope
in the controller. Check out the modification of your fiddle http://jsfiddle.net/lpiepiora/ntszE/2/
Basically you have to define a controller
function MyCtrl($scope) {
$scope.deposit = 4;
$scope.showValue = function() {
alert($scope.deposit);
};
};
and then bind it using the ng-controller
directive: ng-controller="MyCtrl"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With