我决定对Angular的测试特性进行实验。我已经有了一个应用程序,所以我只是运行了ng test
,它立刻就出现了我不理解的错误。这是我第一次运行角度测试。
下面是输出:
AppComponent should create the app
Failed: Template parse errors:
Can't bind to 'routerLink' since it isn't a known property of 'button'. ("<mat-toolbar color="primary">
<mat-toolbar-row>
<button mat-button [ERROR ->][routerLink]="'/'">{{title}}</button>
<button mat-button (click)="login()" *ngIf="!user">Logi"): ng:///DynamicTestModule/AppComponent.html@2:27
'mat-toolbar-row' is not a known element:
1. If 'mat-toolbar-row' is an Angular component, then verify that it is part of this module.
2. If 'mat-toolbar-row' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("<mat-toolbar color="primary">
下面是app.component.html
中的超文本标记语言片段
<button mat-button [routerLink]="[ ... ]">{{title}}</button>
我明确地将RouterModule
导入到了app.module.ts
中
@NgModule({
declarations: [
...
],
imports: [
RouterModule.forRoot(routes),
...
],
...
})
export class AppModule {}
https://stackoverflow.com/questions/51527464
复制相似问题