I'm using angular 13, and i have to load a menu dynamically from Database so i have a function doing that name's loadMenu() , and i have to put the sidebare (where i have to put the menu loaded) in MetisMenu, but the problem is MetisMenu didn't work correcly without settimeout()
this is my code :
ngOnInit(): void {
this.LoadMenu();
}
LoadMenu() {
if (this.sessionManager.context != null) {
let arg = new P();
this.service.getMenu(arg).subscribe(
data => {
this._menu = data;
},
error => {
console.log(error);
}
);
}}
ngAfterViewInit() {
setTimeout(() => {
new MetisMenu(this.sidebarMenu.nativeElement);
this._activateMenuDropdown();
}, 1000);}