Never use ng-init
, the way you use it is exactly what it is recommended not to do, there are few uses of ng-init
that are considered appropriate, it is usually recommended to initialize the values in the Controller.
In your case there is still another error that is the use of ng-value
, it was not meant to be used in a input
tag except for input[type=radio]
and the option
tag, for tags value input
only ng-model
is required.
So the data should be started in your controller instead of
ng-init
, and it all depends on how your data comes in, simplifying could be
selecionou($stateParams.id);
function selecionou(id) {
$pouchDB.get(id).then(function(resp){
$scope.dados = resp;
});
}
Considering that you are using a PouchDB wrapper for AngularJS then you should not need to call $scope.apply()
Your template should basically be
{{dados.valor}}
<input type="text" ng-model="dados.valor" />
As we use $scope.dados
to save the result of the query then we can also use it directly in the binding, any value that the user will change will be automatically changed in the object.
And just remembering that when you change the value by javascript you should never change directly in input
, you should only change the values in your $scope
and let the angle update the bindings automatically.