npm包中的Angular2组件templateUrl

时间:2016-11-04 09:00:29

标签: angular typescript npm systemjs angular2-components

我在npm模块中编写了一个常用的组件,我不知道引用templateUrl的最佳方式是什么,它正在工作但我不知道希望在node_modules中包含templateUrl,因为可以重命名node_module目标。

还有其他工作方式可以使用吗?

例如:"npm:my-commons-ts/my-commons/components/BootstrapAlert/BootstrapAlert.html"

@Component({
    selector: "bs-alert",
    templateUrl: "node_modules/my-commons-ts/my-commons/components/BootstrapAlert/BootstrapAlert.html",
})
export class BootstrapAlertComponent {

  public errors: DisplayMessage[] = [];
  public successes: DisplayMessage[] = [];
  public warnings: DisplayMessage[] = [];
  public infos: DisplayMessage[] = [];

  @Input()
  public bcn: string = null;

  ...
}

我使用systemjs加载模块。

1 个答案:

答案 0 :(得分:1)

模板未通过SystemJS加载,因此您无法使用其映射。

请注意,您可以使用相对路径,例如../BootstrapAlert/BootstrapAlert.html,还有某些构建工具的模板内联,例如gulp T: X + Y

相关问题