我遇到的问题是,如果我使用应该显示特定组件的网址重新加载我的应用程序,我的应用程序将显示默认页面。例如,我想直接通过浏览器(刷新)转到/ create / user,他会向我显示我的默认页面。
这是我的路线配置。
import {provideRouter, RouterConfig} from '@angular/router';
import {GenericRequestEndpoint} from './components/dynamicresponsetable/dynamicresponsetable.component';
import {DynamicDisplayForm} from './components/dynamicdisplaycomponent/dynamic.display.component';
import {DynamicCreationComponent} from './components/dynamiccreationcomponent/dynamic.creation.component';
import {LoginComponent} from './components/login/login.component';
import {AuthService} from './components/services/auth.service';
import {AuthGuard} from './components/services/auth-guard.service';
import {Dummy} from './components/dummy';
import {ConfigurationComponent} from './components/configurationcomponent/configuration.component';
export const ROUTER: RouterConfig = [
{
path: '',
component: LoginComponent
},
{
path: 'dashboard',
component: Dummy,
canActivate: [AuthGuard]
},
{
path: 'endpoint/:endpointname',
component: GenericRequestEndpoint,
canActivate: [AuthGuard]
},
{
path: 'detail/:specificitem',
component: DynamicDisplayForm,
canActivate: [AuthGuard]
},
{
path: 'create/:endpointname',
component: DynamicCreationComponent,
canActivate: [AuthGuard]
},
{
path: 'configurator/:endpointname',
component: ConfigurationComponent,
canActivate: [AuthGuard]
}
];
export const APP_ROUTER_PROVIDERS = [
provideRouter(ROUTER), AuthService, AuthGuard
];
答案 0 :(得分:1)
如果使用空路径''
,没有子路由,则添加pathMatch
{
path: '',
component: LoginComponent,
pathMatch: 'full'
},