I have a dropdown that I want to initialize with materialize in navbar.component.html
<select>
<option *ngFor="let survey of surveys" value="{{survey.sid}}">
{{survey.surveyls_title}}</option>
</select>
I get the data from navbar.component.ts
surveys: Survey[] = [];
private loadAllSurveys(){
this.surveyService.getAll().subscribe(surveys => { this.surveys = surveys; });
}
/* Aquí inicializo un sidenav de materialize */
ngAfterViewInit(){
$(document).ready(function(){
$(".button-collapse").sideNav({
menuWidth: 300,
edge: 'right',
closeOnClick: true,
draggable: true
});
});
}
The problem I have is that I do not know how to initialize, I mean where to place the:
$('select').material_select();
so that it is executed after painting the data obtained by means of the subscribe, because otherwise it is empty and inseparable.