how detect unsaved page changes check while moving page or tab in angularjs 1.5 application. 1 of approach using directives how pass related form named directive instead of using hard coded solution?
i tried using service approach mentioned below nested view controller not able access form name. iam getting $scope.myform undefined.
you can handle page change event $locationchangestart ng-route or $statechangestart ui-router (perform logic want inside):
$scope.$on('$locationchangestart', function(event) { if ($scope.myform.$invalid) { event.preventdefault(); } }); to tab change etc, can disable tab or watever approach prefer
ng-disabled="!myform.$valid" edit
you may @ post use service/factory approach : https://stackoverflow.com/a/25459689/5138917
Comments
Post a Comment