Ngx-bootstrap: Custom modal content

Created on 21 Jul 2017  路  2Comments  路  Source: valor-software/ngx-bootstrap

It would be awesome if we could pass some custom content to the ModalComponent in the following way: modalService.show(ModalComponent, customContent) method.

comp(modal) feat-request

Most helpful comment

I have found a workaround as follows:

var modalRef = this.bsModalService.show(ModalComponent);
var modalComponent = modalRef.content as ModalComponent;
modalComponent.title = "Title";
modalComponent.updateView();

In your component inject private cd: ChangeDetectorRef and add the updateView method:

updateView() {
    this.cd.detectChanges();
}

But it would be nicer that the show method BsModalService provided a way to pass data directly.
A discussion at ng-bootstrap about this has already taken place:
https://github.com/ng-bootstrap/ng-bootstrap/issues/861

All 2 comments

I second

I have found a workaround as follows:

var modalRef = this.bsModalService.show(ModalComponent);
var modalComponent = modalRef.content as ModalComponent;
modalComponent.title = "Title";
modalComponent.updateView();

In your component inject private cd: ChangeDetectorRef and add the updateView method:

updateView() {
    this.cd.detectChanges();
}

But it would be nicer that the show method BsModalService provided a way to pass data directly.
A discussion at ng-bootstrap about this has already taken place:
https://github.com/ng-bootstrap/ng-bootstrap/issues/861

Was this page helpful?
0 / 5 - 0 ratings