{"id":18878636,"url":"https://github.com/nowzoo/nz-bs-modal","last_synced_at":"2026-05-09T19:42:40.880Z","repository":{"id":93412721,"uuid":"135007777","full_name":"nowzoo/nz-bs-modal","owner":"nowzoo","description":"Bootstrap Modals for Angular 6","archived":false,"fork":false,"pushed_at":"2018-05-28T20:23:03.000Z","size":3101,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-25T08:21:13.691Z","etag":null,"topics":["angular","angular6","bootstrap","modal"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/nowzoo.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":"2018-05-27T01:53:13.000Z","updated_at":"2018-05-28T20:17:10.000Z","dependencies_parsed_at":"2023-05-23T00:00:17.125Z","dependency_job_id":null,"html_url":"https://github.com/nowzoo/nz-bs-modal","commit_stats":{"total_commits":93,"total_committers":1,"mean_commits":93.0,"dds":0.0,"last_synced_commit":"710d9f74ed116037133d59edd4e3fd27a1d0f2cf"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nowzoo%2Fnz-bs-modal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nowzoo%2Fnz-bs-modal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nowzoo%2Fnz-bs-modal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nowzoo%2Fnz-bs-modal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nowzoo","download_url":"https://codeload.github.com/nowzoo/nz-bs-modal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239841731,"owners_count":19705981,"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":["angular","angular6","bootstrap","modal"],"created_at":"2024-11-08T06:28:43.718Z","updated_at":"2026-02-19T17:30:17.527Z","avatar_url":"https://github.com/nowzoo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NzBsModal\n\nBootstrap modal library for Angular 6. Built on top of the Bootstrap js, with full support for modal styling, animations, options and events.\n\n[Demo Site](https://nowzoo.github.io/nz-bs-modal)\n\n**NB:** By design this library depends on jQuery, popper.js, bootstrap.js and bootstrap.css. You need to include those scripts and styles in your build. If you are looking for a native Angular implementation, look at [ngx-bootstrap](https://github.com/valor-software/ngx-bootstrap) or [ng-bootstrap](https://ng-bootstrap.github.io).\n\n## Get Started\n### Install the Library \u0026amp; Dependencies\n```bash\nnpm i --save nzbs-modal jQuery popper.js bootstrap\n```\n### Include the JS and CSS Dependencies in Your Build\n\nAdd the following entries in the `styles` and `scripts` sections of your project in `angular.json`. [Real-life example](https://github.com/nowzoo/nz-bs-modal/blob/master/angular.json#L32).\n```json\n\"styles\": [\n  \"node_modules/bootstrap/scss/bootstrap.scss\",\n  \"src/styles.scss\"\n],\n\"scripts\": [\n  \"node_modules/jquery/dist/jquery.slim.min.js\",\n  \"node_modules/popper.js/dist/umd/popper.min.js\",\n  \"node_modules/bootstrap/dist/js/bootstrap.min.js\"\n]\n\n```\n\nAlternately, you can include the Bootstrap styles in your app stylesheet...\n\n```scss\n// src/styles.scss...\n@import \"~bootstrap/scss/bootstrap\";\n// more styles...\n```\n\n### Usage\n\nThe library comes with:\n - The `NzBsModalService` [code](https://github.com/nowzoo/nz-bs-modal/blob/master/projects/nz-bs-modal/src/lib/nz-bs-modal.service.ts) which your components will use to show modals. The service's `show()` method returns an instance of `INzBsModalInstance`, which has properties and methods to manipulate the modal once it is shown.\n - The `NzBsModalComponent`. You only need one of these in your app, and it should be placed as high up in the DOM as possible, for example, at the end of your `AppComponent` template. You can pass in some default options if you don't like the built in ones. After that, you really don't have to worry about it.\n\n#### Import the ModalModule in your app module\n\nWe only want to have one instance of the Modal Service, so call `NzBsModalComponent.forRoot()`.\n\n```ts\n// src/app/app.module.ts\nimport { NzBsModalModule } from 'nzbs-modal';\n\n@NgModule({\n  imports: [\n    // other imports\n    NzBsModalModule.forRoot()\n  ],\n  bootstrap: [AppComponent]\n})\nexport class AppModule { }\n```\n[Full example](https://github.com/nowzoo/nz-bs-modal/blob/master/src/app/app.module.ts#L1).\n\n#### Add the ModalComponent to your app component\nInsert the component selector `\u003cnz-bs-modal\u003e\u003c/nz-bs-modal\u003e` at the bottom of `app.component.html`.\n```html\n\u003c!-- app.component.html --\u003e\n\u003cdiv style=\"padding-top:56px\"\u003e\n  \u003crouter-outlet\u003e\u003c/router-outlet\u003e\n\u003c/div\u003e\n\u003cnz-bs-modal\u003e\u003c/nz-bs-modal\u003e\n```\n[Full example](https://github.com/nowzoo/nz-bs-modal/blob/master/src/app/app.component.html#L1).\n\n#### Minimal Example: Use the service to display modals from other components\n\n[Demo Source](https://github.com/nowzoo/nz-bs-modal/tree/master/src/app/demos/minimal)\n\nFirst, add an `\u003cng-template\u003e` to your component's template. Make sure to reference it with a template reference variable, e.g. `#modal`. It should probably contain at least a `.modal-body` div.\n\n```html\n\u003c!-- minimal.component.html --\u003e\n\u003cdiv class=\"d-flex align-items-center mb-2\"\u003e\n  \u003cdiv\u003e\n    \u003cbutton type=\"button\" class=\"btn btn-primary btn-lg\" (click)=\"showModal()\"\u003e\n      Show Modal\n    \u003c/button\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n\u003cng-template #modal\u003e\n  \u003cdiv class=\"modal-content\"\u003e\n    \u003cdiv class=\"modal-header\"\u003e\n      \u003ch5 class=\"modal-title\" [attr.id]=\"modalLabelledById\"\u003eWhat's Up?\u003c/h5\u003e\n      \u003cbutton type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"\u003e\n        \u003cspan aria-hidden=\"true\"\u003e\u0026times;\u003c/span\u003e\n      \u003c/button\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"modal-body\"\u003e\n      \u003cp\u003eHey! Here's some modal content.\u003c/p\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"modal-footer\"\u003e\n      \u003cbutton type=\"button\" class=\"btn btn-primary\"\n        data-dismiss=\"modal\"\u003eClose Modal\u003c/button\u003e\n    \u003c/div\u003e\n  \u003c/div\u003e\n\u003c/ng-template\u003e\n```\n\nInstantiate your component class with the `NzBsModalService` and a reference to the modal template and provide some method to show the modal...\n```ts\n// minimal.component.ts\nimport { Component, TemplateRef, ViewChild } from '@angular/core';\nimport { NzBsModalService } from 'nzbs-modal';\n@Component({\n  selector: 'app-minimal',\n  templateUrl: './minimal.component.html',\n  styleUrls: ['./minimal.component.scss']\n})\nexport class MinimalComponent {\n\n  @ViewChild('modal') modal: TemplateRef\u003cany\u003e;\n  constructor(\n    private modalService: NzBsModalService\n  ) { }\n\n  showModal() {\n    this.modalService.show(this.modal);\n  }\n}\n```\n\nNote: In the minimal example above, we used the native Bootstrap `data-dismiss=\"modal\"` attribute to close the modal. Modals can also be closed programmatically, for example, after a successful form submission. `ModalService.show()` returns an instance of `IModalInstance`, which comes with a `hide()` method.\n\n\n## API\n\n### `INzBsModalInstance`\nThis is what the modal service returns from the `show()` method. This interface exposes several methods and properties to manipulate the modal after it is shown.\n\n- `events: EventEmitter\u003cEvent\u003e` exposes the native Bootstrap modal events.\n[Demo](https://nowzoo.github.io/nz-bs-modal/#events) |\n[Demo code](https://github.com/nowzoo/nz-bs-modal/tree/master/src/app/demos/events)\n- `handleUpdate(): void` exposes the native Bootstrap method. You should call this whenever the height of your modal content changes.\n[Demo](https://nowzoo.github.io/nz-bs-modal/#handle-update) |\n[Demo code](https://github.com/nowzoo/nz-bs-modal/tree/master/src/app/demos/handle-update)\n- `shown(): Promise\u003cvoid\u003e` returns a promise that resolves when the modal is completely shown.\n- `hidden(): Promise\u003cvoid\u003e` returns a promise that resolves when the modal is completely hidden.\n- `hide(): void` hides the modal programmatically.\n[Demo for shown(), hidden() and hide()](https://nowzoo.github.io/nz-bs-modal/#prove-you-can-add) |\n[Demo code](https://github.com/nowzoo/nz-bs-modal/tree/master/src/app/demos/prove-you-can-add)\n\n\n### `INzBsModalOptions`\nThe set of options that you can pass into the service's `show()` method. You can also pass your own defaults into the `NzBsModalComponent` instance if you don't like the following defaults.\n\nNote: All of the [Bootstrap modal options and classes](http://getbootstrap.com/docs/4.1/components/modal) except `show` are supported. In addition, we add the Angular-specific `dismissOnRouteChange` option.\n\nNote: All of the following keys are optional.\n\n- `animate?: boolean` **Default:** `true`. Whether or not to animate the modal in and out.\n[Demo](https://nowzoo.github.io/nz-bs-modal/#animate) |\n[Demo code](https://github.com/nowzoo/nz-bs-modal/tree/master/src/app/demos/animate)\n- `size?: 'sm' | 'lg' | null` **Default:** `null`. The size of the modal.\n[Demo](https://nowzoo.github.io/nz-bs-modal/#size) |\n[Demo code](https://github.com/nowzoo/nz-bs-modal/tree/master/src/app/demos/size)\n- `centered?: boolean` **Default:** `false`. Whether to center the modal vertically in the viewport.\n[Demo](https://nowzoo.github.io/nz-bs-modal/#centered) |\n[Demo code](https://github.com/nowzoo/nz-bs-modal/tree/master/src/app/demos/centered)\n- `backdrop?: boolean | 'static'` **Default:** `true`. Whether to display a backdrop, and if so whether clicking on it dismisses the modal.  [Demo](https://nowzoo.github.io/nz-bs-modal/#backdrop) |\n[Demo code](https://github.com/nowzoo/nz-bs-modal/tree/master/src/app/demos/backdrop)\n    - `true` \u0026mdash;  backdrop dismisses the modal\n    - `static` \u0026mdash; backdrop doesn't dismiss\n    - `false` \u0026mdash; no backdrop\n\n- `keyboard?: boolean` **Default:** `true`. Whether or not pressing the `esc` key dismisses the modal.\n[Demo](https://nowzoo.github.io/nz-bs-modal/#keyboard) |\n[Demo code](https://github.com/nowzoo/nz-bs-modal/tree/master/src/app/demos/keyboard)\n- `focus?: boolean` **Default:** `true`. Whether or not to focus the modal when shown. Note that you can also use the `modalInstance.shown()` promise to automatically focus inputs within the modal.\n[Demo](https://nowzoo.github.io/nz-bs-modal/#focus) |\n[Demo code](https://github.com/nowzoo/nz-bs-modal/tree/master/src/app/demos/focus)\n- `dismissOnRouteChange?: boolean`  **Default**: `true`. whether or not to dismiss the modal when the route changes.\n[Demo](https://nowzoo.github.io/nz-bs-modal/#dismissOnRouteChange) |\n[Demo code](https://github.com/nowzoo/nz-bs-modal/tree/master/src/app/demos/dismiss-on-route-change)\n\n### `NzBsModalComponent`\nThis is the \"singleton\" component that you should place near the top of the DOM. It only has one input:\n- `@Input() defaultOptions: INzBsModalOptions` Use this if to globally override the default options shown above.\n\n### `NzBsModalService`\nThe service for showing modals.\n- `show(templateRef: TemplateRef\u003cany\u003e, options?: INzBsModalOptions): INzBsModalInstance` Show a modal given a template and (optionally) a modal options object.\n- `getLabelledById(): string` This is meant to allow you to set the id of the `\u003ch5 class=\"modal-title\"\u003eTitle\u003c/h5\u003e`, so as to match the modal element's `aria-labelledby` attribute. See [Bootstrap modal accessibility](http://getbootstrap.com/docs/4.1/components/modal/#accessibility).\n\n\n\n## Development\nPRs, suggestions and issues are welcome. \n\nThis project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.0.3.\n\n**NB** Library support in the CLI is (IMHO) still a work in progress and less than intuitive. Any ideas on how to restructure the project are more than welcome.\n\n- The library code is found in `projects/nz-bs-modal/src`.\n- The demo code (i.e., the app) is found in `app/src`.\n- In order to develop both the library and and the demo code simultaneously, change all the library imports in the demo code from `nzbs-modal` (which should pick up the node module) to `@nzbs-modal` (which is defined as a path in `tsconfig.json`.)\n\n### Unit tests\n- Run `ng test nz-bs-modal` to execute the unit tests for the library\n- Run `ng test` to execute the unit tests for the demos.\n\n### Development server\nRun `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.\n\n## License\n[MIT](https://github.com/nowzoo/nz-bs-modal/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnowzoo%2Fnz-bs-modal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnowzoo%2Fnz-bs-modal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnowzoo%2Fnz-bs-modal/lists"}