{"id":27194697,"url":"https://github.com/nhusby/ng-modal-service","last_synced_at":"2025-04-09T19:04:16.105Z","repository":{"id":286549608,"uuid":"961653425","full_name":"nhusby/ng-modal-service","owner":"nhusby","description":"Simple un-opinionated modal service for Angular","archived":false,"fork":false,"pushed_at":"2025-04-07T00:11:49.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T05:51:07.277Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nhusby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-07T00:11:48.000Z","updated_at":"2025-04-07T04:45:29.000Z","dependencies_parsed_at":"2025-04-07T06:01:24.318Z","dependency_job_id":null,"html_url":"https://github.com/nhusby/ng-modal-service","commit_stats":null,"previous_names":["nhusby/ng-modal-service"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhusby%2Fng-modal-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhusby%2Fng-modal-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhusby%2Fng-modal-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhusby%2Fng-modal-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nhusby","download_url":"https://codeload.github.com/nhusby/ng-modal-service/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248094986,"owners_count":21046770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2025-04-09T19:02:26.208Z","updated_at":"2025-04-09T19:04:16.095Z","avatar_url":"https://github.com/nhusby.png","language":null,"funding_links":[],"categories":["Recently Updated","Third Party Components"],"sub_categories":["[Apr 09, 2025](/content/2025/04/09/README.md)","Modals"],"readme":"# ng-modal-service\n\nA lightweight, flexible Angular modal service that uses the native HTML dialog element.\n\n## Features\n\n- Modern implementation using Angular's standalone components\n- Uses native HTML dialog element for better accessibility\n- Simple API to open and close modals\n- Supports passing data to modal components\n- ESC key and clicking outside closes modal by default\n\n## Installation\n\n```bash\nnpm install ng-modal-service\n```\n\n## Usage\n\n### Import the module\n\n```typescript\nimport { ModalService } from 'ng-modal-service';\n\n@NgModule({\n  imports: [\n    ModalService\n  ]\n})\nexport class AppModule { }\n```\n\n### Create a modal component\n\n```typescript\nimport {Component} from '@angular/core';\nimport {ModalService} from \"ng-modal-service\";\n\n@Component({\n  selector: 'app-example-modal',\n  template: `\n    \u003cheader \u003e\n      \u003ch2\u003e{{ title }}\u003c/h2\u003e\n    \u003c/header\u003e\n    \u003cp\u003e\n      {{ message }}\n    \u003c/p\u003e\n    \u003cfooter\u003e\n      \u003cbutton (click)=\"close()\"\u003eClose\u003c/button\u003e\n    \u003c/footer\u003e\n  `,\n})\nexport class ExampleModalComponent {\n  title = 'Example Modal';\n  message = 'This is an example modal';\n\n  constructor(protected modalService: ModalService) {}\n\n  close() {\n    this.modalService.close(this);\n  }\n}\n```\n\n### Use the service to open and close modals\n\n```typescript\nimport { Component } from '@angular/core';\nimport { ModalService } from 'ng-modal-service';\nimport { ExampleModalComponent } from './example-modal.component';\n\n@Component({\n  selector: 'app-root',\n  template: `\n    \u003cbutton (click)=\"openModal()\"\u003eOpen Modal\u003c/button\u003e\n  `,\n})\nexport class AppComponent {\n  constructor(private modalService: ModalService) {}\n\n  openModal() {\n    const exampleModalComponent = this.modalService.open(ExampleModalComponent, {\n      title: 'Custom Title',\n      message: 'This is a custom message',\n    });\n    \n    // use the modalService to close it\n    // modalService.close(exampleModalComponent);\n  }\n}\n```\n\n[//]: # ()\n[//]: # (## Styling)\n\n[//]: # ()\n[//]: # (Import the default styles in your global styles file:)\n\n[//]: # ()\n[//]: # (```scss)\n\n[//]: # (@import 'node_modules/ng-modal-service/lib/styles/modal.scss';)\n\n[//]: # (```)\n\n[//]: # ()\n[//]: # (Or override them with your own styles.)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhusby%2Fng-modal-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhusby%2Fng-modal-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhusby%2Fng-modal-service/lists"}