Get ng template from angular 2 component

how can i get an element in angular 2? in case i have it in html

<ng-template #content let-c="close" let-d="dismiss">
  <div class="modal-header">Header</div>
   <div class="modal-body">Body</div>
  <div class="modal-footer">footer</div>
</ng-template>

I use this for ngBmodal ng-bootstrap if I use a button for open content then its work = button

(click)="open(content,data.id)"

then I would like to open the content from the component in this case im redirect from another page and open the content

ngOnInit() {
    this.activatedRoute.queryParams.subscribe((params: Params) => {
        let id = params['id'];
        if(id != undefined){
          this.open('content',id);         
        }
      });
  }
open(content, id) {
    this.dataModal = {};
    this.getDataModal(id);

    this.mr = this.modalService.open(content, { size: 'lg' });
  }

modal open, but not with html, I will try afterviewinit to get #content, it doesn't work thanks, sorry for my english: v

+4
source share

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


All Articles