Quantcast
Channel: Is there a pattern for dealing with "Cancel" in AngularJS modal dialogs? - Stack Overflow
Viewing all articles
Browse latest Browse all 7

Answer by Silvan Hofer for Is there a pattern for dealing with "Cancel" in AngularJS modal dialogs?

$
0
0

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="{ updateOn: 'submit' }" name="userName">
    <button type="submit">save</button>
    <button type="button"  ng-click="userForm.userName.$rollbackViewValue();">cancel</button>
</form>

JSFiddle: http://jsfiddle.net/8btk5/104/


Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>