Reputation: 5152
I'd like to add what amounts to a static HTML page into my JHipster app. The body of the page will be static (a privacy policy), but I want it to use the same navbar as other pages so they all have the same look and feel and can navigate seamlessly between other pages.
I tried creating a new angular component
using angular CLI:
> ng generate component privacy-policy
CREATE src/main/webapp/app/privacy-policy/privacy-policy.component.html (33 bytes)
CREATE src/main/webapp/app/privacy-policy/privacy-policy.component.ts (265 bytes)
UPDATE src/main/webapp/app/app.module.ts (2879 bytes)
I'm confused on how to configure routing for this so that /privacy-policy
resolves to this new component. I tried creating a new router for this component as follows but it didn't work:
import { Route } from '@angular/router';
import {PrivacyPolicyComponent} from 'app/privacy-policy/privacy-policy.component';
export const privacyPolicyRoute: Route = {
path: 'privacy-policy',
component: PrivacyPolicyComponent,
outlet: 'privacy-policy'
};
I also tried updating the generated app-routing.module.ts
file to include the new component but that also didn't work:
import {privacyPolicyRoute} from 'app/privacy-policy/privacy-policy.route';
...
const LAYOUT_ROUTES = [privacyPolicyRoute, navbarRoute, ...errorRoute];
No matter what I get the following browser error:
Router Event: NavigationError platform-browser.js:216
NavigationError(id: 2, url: '/privacy-policy', error: Error: Cannot match any routes. URL Segment: 'privacy-policy') platform-browser.js:211
Object { id: 2, url: "/privacy-policy", error: Error }
How can I get my app to properly route requests to my new component?
Upvotes: 0
Views: 1183
Reputation: 6004
Why do you need outlet: 'privacy-policy'
? Remove it. You're probably trying to place the component into an outlet which doesn't exist.
Upvotes: 1