Answer by dalcam for Is there a pattern for dealing with "Cancel" in...
Another way is to copy the model before editing it, and on cancel, restore the original. Angular Controller Code: //on edit, make a copy of the original model and store it on scope function...
View ArticleAnswer by Silvan Hofer for Is there a pattern for dealing with "Cancel" in...
As of Angular 1.3 there is ngModelOptions directive that allows to achive the same behaviour natively. <form name="userForm"> <input type="text" ng-model="user.name" ng-model-options="{...
View ArticleAnswer by Dizzypointed for Is there a pattern for dealing with "Cancel" in...
Here's my try at keeping it simple, making it declarative and not dependent on form tags or other stuff. A simple directive: .directive("myDirective", function(){ return { scope: { item: "=myDirective"...
View ArticleAnswer by vitalets for Is there a pattern for dealing with "Cancel" in...
Facing the same problem and going though this thread I came up with lazy-model directive that works exactly like ng-model but saves changes only when form was submitted. Usage: <input type="text"...
View ArticleAnswer by garst for Is there a pattern for dealing with "Cancel" in AngularJS...
Basically, in angular if something is not declarative, you make a directive. .directive('shadow', function() { return { scope: { target: '=shadow' }, link: function(scope, el, att) { scope[att.shadow]...
View ArticleAnswer by Sharondio for Is there a pattern for dealing with "Cancel" in...
You seem to be over-thinking this. There isn't a plug-in because the process is pretty simple. If you want a pristine copy of the model, make one and keep it in the controller. If a user cancels, reset...
View ArticleIs there a pattern for dealing with "Cancel" in AngularJS modal dialogs?
Note: This is not about showing a modal dialog with AngularJS, that topic has plenty of questions and answers! This question is about how to react to both OK and Cancel within a modal dialog on a...
View Article