I've some fields, they can be edited. The user can cancel the edition mode with the button 'Cancel':
<button ng-click="cancelEdit();" ng-show="editable">
<i class="fa fa-remove"></i> Cancel
</button>
The event ng-click call the function cancelEdit().
$scope.cancelEdit = function(){
$scope.editable=false;
$scope.jobNameInput = $scope.jobToView.name;
$scope.selectedPriority = $scope.jobToView.priority;
$scope.jobCommentsInput = $scope.jobToView.comments;
}
In this function, I just want to set the boolean variable for edition mode to false and reinit the values of my inputs to the default value (before edition mode). After this function is calling, the values are updated for the controller, but not in my view:
<button ng-click="editable=true;" ng-show="!editable">
<i class="fa fa-edit"></i> Edit
</button>
This button is shown when the variable editable is set to false. So when I click on the cancel button, theoretically, the button Edit must be shown and my inputs should be updated. Why is this not the case ?
$scope.jobNameInputand the other values in the view? What's the vaue of $scope.jobToView.name? If you could make a snipped or a plnkr, that would be great. So we can assist you better.<input type="text" ng-model="jobCommentsInput" ng-value="jobToView.comments" ng-disabled="!editable" />