I'm trying to add a new menu item to the default generated JHipster app. I'm using Angular 4 by the way.
The problem I'm facing is that I'm always getting the error below.
Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'user-profile'
The following are the codes I added.
Firstly, I added a folder named user-profile under src/main/webapp/app.
In it, I added index.ts, user-profile.component.html, user-profile.component.ts and user-profile.route.ts
The contents of index.ts
export * from './user-profile.component';
export * from './user-profile.route';
The contents of user-profile.component.ts
import { Component, OnInit } from '@angular/core';
import { Principal } from '../shared';
@Component({
selector: 'jhi-user-profile',
templateUrl: './user-profile.component.html'
})
export class UserProfileComponent implements OnInit {
account: Account;
constructor(private principal: Principal) {}
ngOnInit() {
this.principal.identity().then((account) => {
this.account = account;
});
}
}
The contents of user-profile.route.ts
import { Route } from '@angular/router';
import { UserRouteAccessService } from '../shared';
import { UserProfileComponent } from './';
export const userProfileRoute: Route = {
path: 'user-profile',
component: UserProfileComponent,
data: {
authorities: [],
pageTitle: 'user-profile.title'
}
};
The contents of user-profile.component.html
<div>Hello World!</div>
I also modified navbar.html to include a new menu item with the following routerlink
routerLink="user-profile"
Any help to this problem will be greatly appreciated.
Thanks.