I created one ng-template with two text fields. I am trying to open this template popup when my screen loads. But when I pass my id its not working.
<ng-template #contentreset let-c="close" let-d="dismiss">
<div class="modal-header">
<p class="modal-title" style="color:black;font-weight: bold;font-size:14px;">Reset password</p>
<button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<
</div>
ngOnInit() {
this.modalService.open(contentreset,{ centered: true }); //here modalservice is NgbModal
});
I tried passing the value from other button click but it doesnt worked. How to pass the ng template id while the page loads
your view is not loaded try it on
ngAfterViewInit() {
} life cycle of component
like this:
ngAfterViewInit() {
this.modalService.open(contentreset,{ centered: true }); //here modalservice is NgbModal
});
More on LIFE_CYCLE_HOOKS
before using ngTemplate
we need to create it's tempateRef in component, so try like this
@ViewChild('contentreset ') contentreset : TemplateRef<any>;
call this template in ngAfterViewInit()
for more info have look here
ngAfterViewInit() {
this.modalService.open(this.contentreset,{ centered: true }); //here modalservice is NgbModal
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.