{"id":21960516,"url":"https://github.com/evolkmann/ngx-pending-changes","last_synced_at":"2026-05-14T12:32:46.776Z","repository":{"id":37069169,"uuid":"400760545","full_name":"evolkmann/ngx-pending-changes","owner":"evolkmann","description":"Router Guard and Component to prevent users from leaving a page with pending changes","archived":false,"fork":false,"pushed_at":"2023-04-17T10:36:11.000Z","size":1966,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-10T06:40:13.097Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evolkmann.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-08-28T10:06:45.000Z","updated_at":"2023-05-23T12:00:52.000Z","dependencies_parsed_at":"2023-07-30T04:16:16.787Z","dependency_job_id":null,"html_url":"https://github.com/evolkmann/ngx-pending-changes","commit_stats":null,"previous_names":["exportarts/ngx-pending-changes"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/evolkmann/ngx-pending-changes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolkmann%2Fngx-pending-changes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolkmann%2Fngx-pending-changes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolkmann%2Fngx-pending-changes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolkmann%2Fngx-pending-changes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evolkmann","download_url":"https://codeload.github.com/evolkmann/ngx-pending-changes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolkmann%2Fngx-pending-changes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33024977,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T10:00:34.092Z","updated_at":"2026-05-14T12:32:46.759Z","avatar_url":"https://github.com/evolkmann.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ngx-pending-changes\n\n[![npm](https://img.shields.io/npm/v/ngx-pending-changes)](https://www.npmjs.com/package/ngx-pending-changes)\n[![Build Status](https://github.com/exportarts/ngx-pending-changes/workflows/ci/badge.svg)](https://github.com/exportarts/ngx-pending-changes/actions)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=exportarts_ngx-pending-changes\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=exportarts_ngx-pending-changes)\n\nThis library allows you to prevent users from navigating away from a page that has pending changes.\n\nIt handles navigations inside your app as well as page reloads and closing of the window.\n\n## Installation\n\n- `npm i -E ngx-pending-changes`\n- Optionally configure the module with [providers in your `app.module.ts`](./projects/ngx-pending-changes/src/lib/tokens.ts)\n\n## Demo\n\nHave a look at the [demo](./projects/demo) to browse the code you see active in the GIF.\n\n![demo gif](./docs/images/demo.gif)\n\n**Run the demo locally**\n\n1. `npm i`\n2. `npm start`\n3. Open [http://localhost:4200](http://localhost:4200)\n\n## Example\n\n#### **`routing.module.ts`**\n```ts\nconst routes: Routes = [\n  // ...\n  {\n    path: `:id`,\n    component: DetailComponent,\n    resolve: {\n      transport: DetailResolver\n    },\n    // To re-fetch the transport after it has been updated on the detail view\n    runGuardsAndResolvers: 'always',\n    canDeactivate: [\n      PendingChangesGuard\n    ]\n  },\n  // ...\n];\n```\n\n#### **`detail.component.ts`**\n```ts\nimport { GuardedComponent } from 'ngx-pending-changes';\n\n@Component({\n  selector: 'app-detail',\n  templateUrl: './detail.component.html',\n  styleUrls: ['./detail.component.scss']\n})\nexport class DetailComponent extends GuardedComponent {\n\n  readonly form = new FormGroup({ /* ... */ });\n\n  // This tells the Guard if it should prevent the user from navigating away\n  readonly allowDeactivate = () =\u003e this.form.pristine;\n\n  // You can provide a custom message for the confirm dialog.\n  // You can also provide a global message with a provider.\n  readonly getDeactivateMessage = () =\u003e `You have pending changes. Really leave the page?`;\n\n  // When the form is saved, we change the URL to trigger the resolver\n  save() {\n    this.dataService.save().pipe(\n      switchMap(_ =\u003e this.router.navigate([], {\n        queryParams: {\n          reload: Date.now()\n        },\n        queryParamsHandling: 'merge'\n      })),\n      tap(_ =\u003e this.mode = 'readonly';)\n    ).subscribe();\n  }\n\n}\n```\n\n## Contributing\n\nContributions via issues or Pull Requests are welcome!\n\nWhen making commits, please follow the commit message guidelines from\n[conventionalcommits.org](https://www.conventionalcommits.org).\nThis makes it easy to auto-generate a changelog.\n\nHave a look at previous commits in this repo for examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevolkmann%2Fngx-pending-changes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevolkmann%2Fngx-pending-changes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevolkmann%2Fngx-pending-changes/lists"}