没有将“exportAs”设置为“routerLinkActive”的指令

Gov*_*raj 5 karma-runner angular-material angular

我在我的应用程序中使用 mat 导航列表组件进行选项卡和导航。它在前端完美运行,但在测试用例上抛出错误。

从业力中获取以下错误。

 There is no directive with "exportAs" set to "routerLinkActive" ("        *ngFor="let tab of tabs"
             [routerLink]="tab.path"
             [routerLinkActive] [ERROR ->]#rla="routerLinkActive"
             [active]="rla.isActive"
             selectedIndex="0"
Run Code Online (Sandbox Code Playgroud)

组件.html

<nav mat-tab-nav-bar>
        <a
            mat-tab-link
            *ngFor="let tab of tabs"
            [routerLink]="tab.path"
            [routerLinkActive] #rla="routerLinkActive"
            [active]="rla.isActive"
            selectedIndex="0"
        >
            <i class="{{tab.icon}}"></i>
            {{ tab.label }}
        </a>
    </nav>
Run Code Online (Sandbox Code Playgroud)

Gov*_*raj 4

参考 Angular 4 Error: Noprovider for ChildrenOutletContexts in Karma-Jasmine 测试线程添加了 RouterTestingModule。

解决了业力错误。