I've taken Metronic 9.2, and converted it to angular sucessfully with demo 1.
When I initially launch Metronic it appears to work, but after a route change KTUI stops working after a route is changed.
I have tried to initiatlise KtUi manually like this in the app.component :
constructor() {
this.router.events.pipe(filter(e => e instanceof NavigationEnd)).subscribe(() => {
this.updateDemo();
// Delay initialization to ensure view is rendered
setTimeout(() => {
this.metronicInitService.init();
}, 0);
});
this.updateDemo();
}
It works again if I refresh the page using the refresh option via the browser.
Hi
Use requestAnimationFrame instead of setTimeout for better timing:
constructor() {
this.router.events.pipe(
filter(e => e instanceof NavigationEnd),
// Unsubscribe to prevent memory leaks
takeUntil(this.destroy$)
).subscribe(() => {
this.updateDemo();
// Use requestAnimationFrame for better timing
requestAnimationFrame(() => {
requestAnimationFrame(() => {
this.metronicInitService.init();
});
});
});
this.updateDemo();
} setTimeout(() => {
this.metronicInitService.init();
}, 100); // Increase delay to 100ms