首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >10个规范,10次失败-无法绑定到'routerLink‘,因为它不是'button’的已知属性

10个规范,10次失败-无法绑定到'routerLink‘,因为它不是'button’的已知属性
EN

Stack Overflow用户
提问于 2018-07-26 04:51:17
回答 1查看 220关注 0票数 0

我决定对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 {}
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51527464

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档