That\'s the way I use the ng2-bootstrap modal:
import {Component} from \'@angular/core\';
import {NgbModal} from \'@ng-bootstrap/ng-bootstrap\';
@Component({
There is a better approach to handle data in the modal if you need to have data immediately after modal construction. Using angular injector technic.
class CustomModalOptions {
stringProp: string;
numberProp: number;
}
this.modal.open(MyModal, {
injector: Injector.create([{
provide: CustomModalOptions, useValue: { stringProp: "foo bar", numberProp: 17 }
}], this.injector)
});
@Component({ ... })
class MyModal {
constructor(private options: CustomModalOptions) {
console.log(this.options.stringProp);
console.log(this.options.numberProp);
}
}