Open ng-bootstrap program code

I have an angular 4 page including an ng-bootstrap modem. My code is as follows.

foo.html

[...] <button class="btn btn-sm btn-secondary material-icons" (click)="open(content)">search</button> <ng-template #content let-c="close" let-d="dismiss"> content in here </ng-template> [...] 

foo.ts

 [...] constructor(private modalService: NgbModal) { } [...] open(content) { let options: NgbModalOptions = { size: 'lg' }; this.modalService.open(content, options); } [...] 

Now, when I click the button, the modal opens. Now I want to open a model on ngChanges.

 ngOnChanges(changes: any) { open(content) } 

My problem: how do I get the "content" here? Is there a way to get the ng program template? Thanks in advance!

+5
source share
1 answer

In the constructor add:

  import { ViewChild } from '@angular/core'; 

before the constructor (), add:

 @ViewChild('content') private content; 

and finally:

 ngOnChanges(changes: any) { this.open(this.content); } 
+9
source

Source: https://habr.com/ru/post/1269880/


All Articles