ng-unsaved-changes

0.0.2 • Public • Published

ng-unsaved-changes

An angular directive to notify the user before leaving a page with unsaved changes in forms.

usage

npm i ng-unsaved-changes
# or 
bower install ng-unsaved-changes
angular.module('myApp', ['io.dennis.unsaved-changes'])
  .run(SetupUnsavedChanges);
 
SetupUnsavedChanges.$inject = ['UnsavedChangedService'];
function SetupUnsavedChanges($unsavedChanges) {
  $unsavedChanges.setInterceptor(myInterceptor);
  $unsavedChanges.setMessage('You have unsaved changes, really leave?');
 
  function myInterceptor(confirm) {
    // show your user whatever you want to warn him about leaving a page
    // with unsaved changes. Look at the demo to see an example of how to display
    // a modal with a warning
 
    // if your user confirms that he want to leave, call confirm ->
    confirm();
  }
}
<form ng-unsaved-changes>
  <!-- ... --->
</form>

Currently only works for forms!

license

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i ng-unsaved-changes

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • ds82