angular4

时间:2017-11-28 11:31:53

标签: angular angular2-routing

我在角度4中得到一个非常奇怪的错误路由,我不知道如何解决它。 错误信息是:

  

错误错误:未捕获(在承诺中):错误:无令牌错误:无令牌       at viewWrappedDebugError(/vendor.bundle.js:128545)       at callWithDebugContext(/vendor.bundle.js:133596)       在Object.debugCreateRootView [as createRootView](/ vendor.bundle.js:132903)       在ComponentFactory_.webpackJsonp ... / .. / .. / core/@angular/core.es5.js.ComponentFactory_.create   (/vendor.bundle.js:129994)       在ComponentFactoryBoundToModule.webpackJsonp ... / .. / .. / core/@angular/core.es5.js.ComponentFactoryBoundToModule.create   (/vendor.bundle.js:123411)       在ViewContainerRef_.webpackJsonp ... / .. / .. / core/@angular/core.es5.js.ViewContainerRef_.createComponent   (/vendor.bundle.js:130196)       在RouterOutlet.webpackJsonp ... / .. / .. / router / @ angular /router.es5.js.RouterOutlet.activateWith   (/vendor.bundle.js:154164)       在ActivateRoutes.webpackJsonp ... / .. / .. / router / @ angular/router.es5.js.ActivateRoutes.activateRoutes   (/vendor.bundle.js:153303)       在/vendor.bundle.js:153254       在Array.forEach()       at viewWrappedDebugError(/vendor.bundle.js:128545)       at callWithDebugContext(/vendor.bundle.js:133596)       在Object.debugCreateRootView [as createRootView](/ vendor.bundle.js:132903)       在ComponentFactory_.webpackJsonp ... / .. / .. / core/@angular/core.es5.js.ComponentFactory_.create   (/vendor.bundle.js:129994)       在ComponentFactoryBoundToModule.webpackJsonp ... / .. / .. / core/@angular/core.es5.js.ComponentFactoryBoundToModule.create   (/vendor.bundle.js:123411)       在ViewContainerRef_.webpackJsonp ... / .. / .. / core/@angular/core.es5.js.ViewContainerRef_.createComponent   (/vendor.bundle.js:130196)       在RouterOutlet.webpackJsonp ... / .. / .. / router / @ angular /router.es5.js.RouterOutlet.activateWith   (/vendor.bundle.js:154164)       在ActivateRoutes.webpackJsonp ... / .. / .. / router / @ angular/router.es5.js.ActivateRoutes.activateRoutes   (/vendor.bundle.js:153303)       在/vendor.bundle.js:153254       在Array.forEach()       at resolvePromise(/polyfills.bundle.js:6299)       at resolvePromise(/polyfills.bundle.js:6270)       at /polyfills.bundle.js:6347       在ZoneDelegate.webpackJsonp ... / .. / .. / .. / zone.js / dist / zone.js.ZoneDelegate.invokeTask   (/polyfills.bundle.js:5953)       at Object.onInvokeTask(/vendor.bundle.js:124002)       在ZoneDelegate.webpackJsonp ... / .. / .. / .. / zone.js / dist / zone.js.ZoneDelegate.invokeTask   (/polyfills.bundle.js:5952)       在Zone.webpackJsonp ... / .. / .. / .. / zone.js / dist / zone.js.Zone.runTask(/polyfills.bundle.js:5720)       在drainMicroTaskQueue(/polyfills.bundle.js:6113)       在

我的路线配置如下:

const routes: Routes =  [
{
    path: '',
    component: FullLayoutComponent,
    children: []
}];

routes.push({ path: 'login', component: LoginComponent });
routes.push({ path: 'logout', component: LogoutComponent });
routes.push({ path: 'recover', component: RecoverComponent });
routes.push({ path: 'userconfirmemail/:id/:confirmationCode', component: 
ConfirmEmailComponent });
routes.push({ path: 'userresetpassword/:id/:resetCode', component: 
ResetPasswordComponent });
routes.push({ path: '**', redirectTo: 'login' });

routes[0].children.push({ path: '', redirectTo: 'dashboard', canActivate: 
[AuthGuard], pathMatch: 'full' });
routes[0].children.push({ path: 'dashboard', canActivate: [AuthGuard], 
component: DashboardComponent });
routes[0].children.push({ path: 'user', canActivate: [AuthGuard], component: 
UserOverviewComponent, data: { roles: [RoleRights.UsersView] } });

“恢复”和“用户确认”路由出现错误。如果没有用户登录,它就会出现。

登录并调用后续路线时,它可以正常工作。但是恢复路线中没有authguard ..那么..问题到底是什么?!任何人吗?

0 个答案:

没有答案