User527076549 posted
Hi
I am not sure if this is the right place to ask question about angular.Please let me know where i can post angular related question
i have a modal component inside which i have select picker[bootstrap], which i am accessing via ViewChild, below is sample
samplemodal.component.ts file
@Component({
selector: 'samplemodal',
templateUrl: './showlist-modal.component.html',
})
export class ShowListModalComponent implements OnInit{
@ViewChild('selectpickerlist',{static:false}) selectPicker:ElementRef;
constructor(){
}
ngOnInit()
{
}
ngAfterViewChecked(){
this.selectPicker.nativeElement.selectpicker; [thorwing error-nativeElement of undefined]
}
}
maincomponent.html file
<samplemodal #samplemodal></samplemodal>
<button samplemodal.show()></button>
while loading maincomponent,its throwing error at ngAfterViewChecked() saying nativeElement of undefined.And in modalcomponent.ts cant get selectpicker.Really appreciate your help.Thanks in advance.