I have an angular2 component using Material Design Lite but the checkbox (probably others too) elements are not properly rendered at the first load of the component, while if I interact with the checkboxes, the mdl style is correctly applied. In my component I have
ngAfterViewInit() {
componentHandler.upgradeDom();
}
but this does not fix my issue, so I used a setTimeout to be executed just after the service has returned some data. This seems to work but is it recommended to do it like that?
this.service.getDetails(this.id)
.finally(() => {
setTimeout(() => {
componentHandler.upgradeDom();
}, 10);
})
.subscribe((details) => {
this.details = details;
});