Hi,
I decided to change my way of doing and now, i juste create an object user which i bind with my form, but i have exactly the same problem, and when i did what you propose to me, the is no more effect…
Here is my entire code :
.controller(“Peoples”,[‘$scope’, ‘$cordovaSQLite’, ‘$state’, ‘$ionicPopup’, function($scope, $cordovaSQLite, $state, $ionicPopup) {
$scope.user = {
first : '',
last : ''
};
//Every time the view is opened
$scope.$on('$ionicView.enter', function() {
var query = "SELECT * FROM people";
$cordovaSQLite.execute(db, query).then(function(res) {
if(res.rows.length > 0) {
$scope.people = [];
if(res.rows.length > 0) {
for(var i = 0; i < res.rows.length; i++) {
$scope.people.push({firstname: res.rows.item(i).firstname, lastname: res.rows.item(i).lastname, id : res.rows.item(i).id});
}
}
}
}, function (err) {
console.error(err);
});
});
$scope.openadd = function(num) {
if (num == 0)
{
$scope.user = {
first : 'fvdsvd',
last : 'dfvdv'
};
$state.go('addpeople');
}
else
{
$state.go('addpeople');
}
};
And the view :
People, in which you can edit or create or edit a user
<ion-content class="padding">
<ion-list ng-repeat="post in people">
<ion-item href="#">
<h2>{{ post.firstname }} {{post.lastname}}</h2>
<ion-option-button class="button-positive" ng-click="openadd(post.id)">Edit</ion-option-button>
<ion-option-button class="button-assertive" ng-click="showConfirm(post.id)">Delete</ion-option-button>
</ion-item>
</ion-list>
</ion-content>
<div class="testHello">
<a ng-click="openadd(0)" class="button button-icon ion-person-add icon-change">
</a>
</div>
And the view with the form :
<form class="list" novalidate>
<label class="item item-input">
<input type="text" placeholder="First Name" ng-model="user.first" required>
</label>
<div class="padding">
<p ng-show="formAdduser.first.$error.required">First name is required</p>
</div>
<label class="item item-input">
<input type="text" placeholder="Last Name" ng-model="user.last" required>
</label>
<h2>{{test}}</h2>
<div class="padding">
<p ng-show="formAdduser.last.$error.required">Last name is required</p>
</div>
<div class="padding">
<button class="button button-block button-balanced" ng-click="add()">
Valider
</button>
</div>
</form>
</ion-content>
I want that when i update the User object in the methode openadd(), i upadte also the view, but there is no effect. When i dit it on the controller but not in a methode, it works…
What is wrong ?