I have defined my routes like following:
const appRoutes: Routes = [
{
path: 'auth',
component: AuthenticationComponent,
},
{
path: '',
component: HomeComponent,
canActivate:[AuthenticationGuard],
children:[
{
path: 'list',
component: TaskListComponent,
canActivate:[AuthenticationGuard]
},
{
path: 'create',
component: CreateTaskComponent,
canActivate:[AuthenticationGuard]
},
{
path: 'profile',
component: ProfileComponent,
canActivate:[AuthenticationGuard]
},
{
path: 'agreement',
component: UserAgreementComponent,
canActivate:[AuthenticationGuard]
},
]
},
];
And I navigate on them like following:
<nav class="mdl-navigation">
<a class="mdl-navigation__link" href="#/list">List</a>
<a class="mdl-navigation__link" href="#/create">Create</a>
<a class="mdl-navigation__link" href="#/profile">Profile <span *ngIf="profileNotPresent" mdl-badge="Start"></span> </a>
<button class="mdl-button mdl-js-button" (click)="logout()">
<i class="material-icons">exit_to_app</i>
</button>
</nav>
I had to add hash because when I deployed the app it started throwing me 404 error for routes. With hashed urls it works.
However in my code I had a condition where I was showing a div on condition that was true if it was the base route:
if(this.router.url == '/'){
this.showHomeContent=true;
}
that time without hash my urls were '/', '/profile' etc and it used to work corrrrectly. Now they are '#', '#/profile' etc and this condition no longer works resulting in that specific div always remains open.
How can I fix this?
== #/