我不断收到当我试图创建一个角路由链路此错误:角2 RC5模板语法错误
zone.js:461 Unhandled Promise rejection: Template parse errors:
Can't bind to 'routerLink' since it isn't a known property of 'a'. ("
</h1>
<button (click)="doLogin()">Login</button>
<a [ERROR ->][routerLink]="['/createservice']" href="#">Post a Service</a>
<router-outlet></router-outlet>
"): [email protected]:3 ; Zone: <root> ; Task: Promise.then ; Value: BaseExceptionconsoleError @ zone.js:461
zone.js:463 Error: Uncaught (in promise): Template parse errors:(…)
这是我的代码:
<a [routerLink]="['/createservice']" href="#">Post a Service</a>
,并在我的组件我有这样的:
import { RouterLink } from '@angular/router';
@Component({
moduleId: module.id,
selector: 'app-root',
providers: [AngularFire],
templateUrl: 'app.component.html',
styleUrls: ['app.component.css'],
directives: [RouterLink]
})
我也试过这样:
<a routerLink="/createservice" routerLinkActive="active">Post a Service</a>
按照本教程(https://angular.io/docs/ts/latest/guide/router.html#!#router-link),这也不起作用。
这是我如何自举我的应用程序:
@NgModule({
imports: [
BrowserModule,
AngularFireModule.initializeApp(firebaseConfig),
RouterModule,
routing
],
declarations: [ AppComponent, CreateServiceComponent ],
providers: [ appRoutingProviders ],
bootstrap: [ AppComponent,FIREBASE_PROVIDERS ]
})
export class MyAppModule {}
if (environment.production) {
enableProdMode();
}
bootstrap(AppComponent, [
FIREBASE_PROVIDERS,
defaultFirebase(firebaseConfig),
firebaseAuthConfig({
provider: AuthProviders.Facebook,
method: AuthMethods.Popup
})]);
您正在使用哪个angular2版本? –
我正在使用rc5。 – Tyler
你在使用@NgModule吗?请发布如何引导您的应用程序。 – j2L4e