If I return to the same routing path it show an error
"Uncaught (in promise): TypeError: Cannot read property 'isActivated' of undefined".
But not show at first time. can any one help me ?
const mainRoutes: Routes = [
{ path: '', pathMatch: 'full', redirectTo: '/home' },
{
path: 'home', loadChildren: './apps/home/home.module#HomeModule', canActivate: [AuthGuard],
resolve: {
crisis: NavigarionResolve
}
}
{ path: '**', component: PageNotFoundComponent }
];
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from '../main/service/auth.service';
@Component({
selector: 'home-app',
templateUrl: 'apps/home/view/home.component.html',
providers: [AuthService]
})
export class HomeComponent implements OnInit {
loaded: boolean = false;
title = 'Customer Management Home';
slogan = 'Hi ...Home ';
views: Object[] = [];
constructor(private _authService: AuthService, private router: Router) {
this.views = [
{
name: "My Account",
description: "Edit my account information",
icon: "assignment ind"
},
{
name: "Potential dates",
description: "Find your soulmate!",
icon: "pets"
}
];
}
logout() {
this._authService.logout().then(() => {
this.router.navigate(['/login']);
});
}
ngOnInit() {
}
}
this.router.navigate(['/home']);
For me the issue was a second instance of the app being loaded. This was caused by an invalid templateUrl within a "control" component.
I moved a spinner component I have from app/components/client/spinner.component
to app/components/shared/spinner.component
but forgot to update the templateUrl.
This meant that my spinner was loading up inside my other components with the wrong html. I had used the correct path for the component in module.ts
, so it wasn't throwing any build errors, but when it couldn't find the spinner.component.html, mvc6 was returning the default index page, so it tried to load up the entire app from inside the component. This inner app was then being removed once the spinner was removed as my content had loaded.
I don't fully understand it, but it appears the router was having some sort of conflict due to the app being loaded again from inside itself.
In my case, I was lucky enough to notice that my app was glitching, so I paused javascript during the glitchy part and scanned the html, and noticed there was a <html>
tag inside my spinner.
Try setting a breakpoint inside your app.component class and seeing if it gets hit twice, or running document.getElementsByTagName("my-app")
(or whatever your app.component is called) in the console and if you have more than 1 element returned you should be able to debug the problem from there. In my case this only showed while the spinner was showing, so if you have components coming and going on your page, try breaking on each one show/hiding.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With