Friends,
in my controller I have exactly this:
.controller('JornadaCtrl', function($scope) {
var getJornada = function(){
if (!localStorage.Horas){
localStorage.Horas = 8;
}
return parseInt(localStorage.Horas);
}
$scope.qtdeHoras = getJornada();
$scope.salvar = function(){
localStorage.Horas = $scope.qtdeHoras;
alert($scope.qtdeHoras);
}
})
As you can see, I have a property “qtdeHoras”, receiving value from getJornada function. In My view, this property “qtdeHoras” is bind to an input, like this:
<input type="number" ng-model="qtdeHoras"> <br/>
<tt> Value = {{qtdeHoras}}</tt>
In the View, everything is OK, as value get changed in the input, the tt is updated. BUT, I also have a button triggering my “salvar()” function. If you look into it, you see I’m using an alert to display “qtdeHoras” value…and here is the problem.
When I open this view, “qtdeHoras” is “5”, so I change it to “8”. Binding shows this correctly, but when I click my button, is shown the first value “5”, not the “8”…
I can’t see what is wrong here…