import { DemoModalServiceStaticComponent } from './demos/service-template/service-template'; import { DemoModalServiceFromComponent } from './demos/service-component/service-component'; import { DemoModalServiceNestedComponent } from './demos/service-nested/service-nested'; import { DemoModalServiceEventsComponent } from './demos/service-events/service-events'; import { DemoModalServiceOptionsComponent } from './demos/service-options/service-options'; import { DemoModalServiceConfirmWindowComponent } from './demos/service-confirm-window/service-confirm-window'; import { DemoModalStaticComponent } from './demos/static/static'; import { DemoModalSizesComponent } from './demos/sizes/sizes'; import { DemoModalChildComponent } from './demos/child/child'; import { DemoModalNestedComponent } from './demos/nested/nested'; import { DemoModalEventsComponent } from './demos/events/events'; import { DemoAutoShownModalComponent } from './demos/auto-shown/auto-shown'; import { ContentSection } from '../../docs/models/content-section.model'; import { DemoTopSectionComponent } from '../../docs/demo-section-components/demo-top-section/index'; import { ExamplesComponent } from '../../docs/demo-section-components/demo-examples-section/index'; import { ApiSectionsComponent } from '../../docs/demo-section-components/demo-api-section/index'; import { NgApiDocComponent, NgApiDocClassComponent, NgApiDocConfigComponent } from '../../docs/api-docs'; export const demoComponentContent: ContentSection[] = [ { name: 'Usage', anchor: 'usage', outlet: DemoTopSectionComponent, content: { doc: require('html-loader!markdown-loader!./docs/usage.md') } }, { name: 'Service examples', anchor: 'service-section', outlet: ExamplesComponent, description: `
Open a modal from service.
To be able to open modals from service, inject BsModalService to your constructor.
Then, call
.show() method of modal service. Pass a TemplateRef or a component as a first argument and
config as a second (optionally).
.show() method returns an instance of BsModalRef
class with .hide() method and content property where you'll find a component
which you've passed to service.
Creating a modal with component just as easy as it is with template. Just pass your component
in .show() method as in example, and don't forget to include your component to
entryComponents of your NgModule
If you passed a component
to .show() you can get access to opened modal by injecting BsModalRef. See example for
more info
Nested modals are supported
`, outlet: DemoModalServiceNestedComponent }, { title: 'Events', anchor: 'service-events', component: require('!!raw-loader?lang=typescript!./demos/service-events/service-events.ts'), html: require('!!raw-loader?lang=markup!./demos/service-events/service-events.html'), description: `Modal service events. Modal service exposes 4 events: onShow, onShown, onHide, onHidden. See usage example below.
onHide and onHidden emit dismiss reason. Possible values are backdrop-click,
esc or null if modal was closed by direct call of hide()
Modal with buttons to confirm.
`, outlet: DemoModalServiceConfirmWindowComponent }, { title: 'Options', anchor: 'service-options', component: require('!!raw-loader?lang=typescript!./demos/service-options/service-options.ts'), html: require('!!raw-loader?lang=markup!./demos/service-options/service-options.html'), description: `There are some options that you can configure, like animation, backdrop, closing by Esc button, additional css classes. See the demo below to learn how to configure your modal
`, outlet: DemoModalServiceOptionsComponent } ] }, { name: 'Directive examples', anchor: 'directive-section', outlet: ExamplesComponent, description: `Also you can use directive instead of service. See the demos below
`, content: [ { title: 'Static modal', anchor: 'directive-static', component: require('!!raw-loader?lang=typescript!./demos/static/static.ts'), html: require('!!raw-loader?lang=markup!./demos/static/static.html'), outlet: DemoModalStaticComponent }, { title: 'Optional sizes', anchor: 'directive-sizes', component: require('!!raw-loader?lang=typescript!./demos/sizes/sizes.ts'), html: require('!!raw-loader?lang=markup!./demos/sizes/sizes.html'), outlet: DemoModalSizesComponent }, { title: 'Child modal', anchor: 'directive-child', component: require('!!raw-loader?lang=typescript!./demos/child/child.ts'), html: require('!!raw-loader?lang=markup!./demos/child/child.html'), description: `Control modal from parent component
`, outlet: DemoModalChildComponent }, { title: 'Nested modals', anchor: 'directive-nested', component: require('!!raw-loader?lang=typescript!./demos/nested/nested.ts'), html: require('!!raw-loader?lang=markup!./demos/nested/nested.html'), description: `Open a modal from another modal
`, outlet: DemoModalNestedComponent }, { title: 'Modal events', anchor: 'directive-events', component: require('!!raw-loader?lang=typescript!./demos/events/events.ts'), html: require('!!raw-loader?lang=markup!./demos/events/events.html'), description: `ModalDirective exposes 4 events: OnShow, OnShown, OnHide, OnHidden. See
usage example below.
$event is an instance of ModalDirective. There you may
find some useful properties like isShown, dismissReason, etc.
For example, you may want to know which one of user's actions caused closing of a modal.
Just get the value of dismissReason, possible values are backdrop-click,
esc or null if modal was closed by direct call of hide()
Show modal right after it has been initialized. This allows you to keep DOM clean by only
appending visible modals to the DOM using *ngIf directive.
It can also be useful if you want your modal component to perform some initialization operations, but want to defer that until user actually sees modal content. I.e. for a "Select e-mail recipient" modal you might want to defer recipient list loading until the modal is shown.
`, outlet: DemoAutoShownModalComponent } ] }, { name: 'API Reference', anchor: 'api-reference', outlet: ApiSectionsComponent, content: [ { title: 'ModalDirective', anchor: 'modal-directive', outlet: NgApiDocComponent }, { title: 'ModalBackdropComponent', anchor: 'modal-backdrop-component', outlet: NgApiDocComponent }, { title: 'BsModalService', anchor: 'bs-modal-service', outlet: NgApiDocClassComponent }, { title: 'BsModalRef', anchor: 'bs-modal-ref', outlet: NgApiDocClassComponent }, { title: 'ModalOptions', anchor: 'modal-options', outlet: NgApiDocConfigComponent } ] } ];