I faced the same problem and now using the same solution but now I faced
another problem.
What if server respond with error on this PUT? For example 403 Access
Denied.
In this case how can we reject changes and restore project model before
save?
I think we still need to use $watch on the model itself as $watch has
access to old and new values and we can do someting like:
$scope.$watch('project', function (newValue, oldValue, scope) {
newValue.$save().catch(function (rejection) {
scope.project = oldValue;
});
});
What angular experts think about this? Is it correct approach?
четверг, 5 июля 2012 г., 0:22:51 UTC+3 пользователь [email protected]
написал:
>
> <input type="checkbox" ng-model="project.status" ng-true-value="1"
> ng-false-value="0" ng-change="project.$save()"/>
>
> I decided on this approach since I don't want every ng-model update of the
> project to trigger a PUT and I find it self-documenting.
>
> On Wednesday, July 4, 2012 11:06:42 PM UTC+2, Peter Bacon Darwin wrote:
>>
>> So what did you go for in the end?
>>
>>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.