Hi guys,
I am having some problems reading an ng-model from the controller. Perhaps is a silly error, but I don’t know.
I want to do this:
<input type="text" ng-model="code">
<button ng-click="setCode()">Login</button>
And in my controller access that variable like this:
$scope.setCode = function(){
alert($scope.code);
}
That is what I want to do but my code variable is undefined.
What I did (and works) is this:
<input type="text" ng-model="code">
<button ng-click="setCode(code)">Login</button>
And:
$scope.setCode = function(code){
alert(code);
}
Someone can help me please? Thanks!