有一个angular2路由器的问题,似乎当我点击一个链接[routerLink]="['/url']
它的控制台给我一个错误ORIGINAL EXCEPTION: TypeError: Cannot read property 'startsWith' of undefined
。但是,如果我删除routerLink
,只是把一个正常的href
它工作正常。angular2 startsWidth未定义的错误
我根本没有改变任何东西,这个错误刚刚出现无处不在。可以在我的代码中找到任何东西,所以不确定它是否存在依赖性问题。有没有其他人有这个问题?
<a [routerLink]="['/reserve']" class="float-shadow">
Reserve & Collect
</a>
import { Component } from '@angular/core';
import { provideRouter, RouterConfig, CanActivate } from '@angular/router';
import { LoginComponent } from '../login/component/login';
import { DashboardComponent } from '../dashboard/component/dashboard';
import { dragulaCompoment } from '../draggable/components/drag';
import { AuthGuard } from './authguard'
export const routes: RouterConfig = [
{ path: '', component: LoginComponent },
{ path: 'home', component: DashboardComponent },
{ path: 'reserve', component: dragulaCompoment, canActivate: [AuthGuard] },
{ path: 'order', component: dragulaCompoment, canActivate: [AuthGuard] },
{ path: 'save', component: dragulaCompoment, canActivate: [AuthGuard] },
{ path: 'assisted', component: dragulaCompoment, canActivate: [AuthGuard] }
];
export const APP_ROUTER_PROVIDERS = [
provideRouter(routes)
];
Packacge.json角依赖性
"@angular/common": "2.0.0-rc.4",
"@angular/compiler": "2.0.0-rc.4",
"@angular/core": "2.0.0-rc.4",
"@angular/forms": "0.2.0",
"@angular/http": "2.0.0-rc.4",
"@angular/platform-browser": "2.0.0-rc.4",
"@angular/platform-browser-dynamic": "2.0.0-rc.4",
"@angular/router": "3.0.0-beta.1",
"@angular/router-deprecated": "2.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.4",
"angular2-in-memory-web-api": "0.0.14",
你有没有试图消除'/' – AngJobs
请发表您的路线和其组件包含routerLink。 –
这是一个已知问题,https://github.com/angular/angular/issues/9499 – AngJobs