我访问此网址build_site()
,但是角色加载我的网址会更改为http://localhost/calls
。 http标头中没有“位置”
路线追踪:
http://localhost/
要求的完整路线:
Router Event: NavigationStart
platform-browser.umd.js:1051 NavigationStart(id: 1, url: '/')
platform-browser.umd.js:1051 NavigationStart {id: 1, url: "/"}
core.umd.js:2957 Angular is running in the development mode. Call enableProdMode() to enable the production mode.
platform-browser.umd.js:1060 Router Event: RoutesRecognized
platform-browser.umd.js:1051 RoutesRecognized(id: 1, url: '/', urlAfterRedirects: '/', state: Route(url:'', path:''))
platform-browser.umd.js:1051 RoutesRecognized {id: 1, url: "/", urlAfterRedirects: "/", state: RouterStateSnapshot}
platform-browser.umd.js:1060 Router Event: GuardsCheckStart
platform-browser.umd.js:1051 GuardsCheckStart(id: 1, url: '/', urlAfterRedirects: '/', state: Route(url:'', path:''))
platform-browser.umd.js:1051 GuardsCheckStart {id: 1, url: "/", urlAfterRedirects: UrlTree, state: RouterStateSnapshot}
platform-browser.umd.js:1060 Router Event: GuardsCheckEnd
platform-browser.umd.js:1051 GuardsCheckEnd(id: 1, url: '/', urlAfterRedirects: '/', state: Route(url:'', path:''), shouldActivate: true)
platform-browser.umd.js:1051 GuardsCheckEnd {id: 1, url: "/", urlAfterRedirects: UrlTree, state: RouterStateSnapshot, shouldActivate: true}
platform-browser.umd.js:1060 Router Event: NavigationEnd
platform-browser.umd.js:1051 NavigationEnd(id: 1, url: '/', urlAfterRedirects: '/')
platform-browser.umd.js:1051 NavigationEnd {id: 1, url: "/", urlAfterRedirects: "/"}
Angular 4.4.3
编辑这是我的canActivate:
import { RouterModule, Routes } from '@angular/router'
import { CallOperatorAuthComponent } from './auth/call-operator-auth/call-operator-auth.component'
import { CallOperatorAuthGuard } from './auth/call-operator-auth/call-operator-auth.guard'
import { DashboardComponent } from './dashboard/dashboard.component
import { AppComponent } from './app.component'
// TODO: try later implement lazy loading again
const appRoutes: Routes = [
{path: 'login', component: CallOperatorAuthComponent},
{
path: 'calls',
component: CallsComponent,
canActivate: [ CallOperatorAuthGuard ]
},
]
export const routing = RouterModule.forRoot(appRoutes,
{ enableTracing: true } )
答案 0 :(得分:0)
我发现了一个原因。我注入服务,并在其构造函数中重定向到'/'。 谢谢大家的帮助。