1
我創建了一個自定義指令來打開新選項卡中的鏈接,在ng服務器中運行時,它可以工作。但是,當我嘗試在ng build --prod時,顯示以下錯誤:無法解析自定義指令的所有參數
錯誤無法解析C:/ Users/myApp/src/app/directives/open-link-in中的OpenLinkInNewTabDirective的所有參數-new-tab.directive.ts:([object Object],?)。
這裏的指令:
import { Directive, ElementRef, HostListener, Input, Inject } from '@angular/core';
@Directive({ selector: '[newTab]' })
export class OpenLinkInNewTabDirective {
constructor(
private el: ElementRef,
@Inject(Window) private win:Window
) {}
@Input('routerLink') link: string;
@HostListener('mousedown') onMouseEnter() {
this.win.open(this.link || 'main/default');
}
}
我設置 「emitDecoratorMetadata」:在tsconfig.json已經成爲事實。 預先感謝您。
非常感謝你,t他解決了我的問題:) –