Discussions
Angular Routing for iParts
over 5 years ago by Cal Ferguson
I'm developing an iPart for iMIS using angular and I'm curious how to handle the initial view of my app.
If we assume my iPart is being rendered from within a piece of Content, let's say at the following path:
/aaa/bbb/ccc/ddd/content.aspx
And with a relative base href:
<base href="./">
What would be the best way to display my initial view? (let's call the Component HomePageComponent
)
At the moment the only ways I can make it work is to either
- Hardcode the default view based on the content page rendering the app (i.e.
{path: 'content.aspx', component: HomePageComponent}
) - Redirect to it from the wildcard catch all (i.e.
{path: '**', redirectTo: '/home'}
)
I'm not a huge fan of either of these methods as the first one will fall over if I want to render the app somewhere else and the second means I can't use the wildcard catch all to handle improper routes.
Anyone able to provide some clarity on the best way to configure angular iPart routes?
Cal