角度打字稿组件未显示模板

韦斯利·范登·伊迪(Wesley Van den Eede)

解决此问题并解决以下问题:AngularJS指令不显示模板

我想尝试使用角度组件和打字稿进行相同操作,但似乎无法正常工作。该组件只是不显示。

我的html看起来像这样:

<div ng-app="SuperHero">
    <super-man></super-man>
</div>

我的打字稿看起来像这样:

module Application.Components {
    export class superMan implements ng.IComponentOptions {
        template: string = "<h1>Hello from component</h1>";
    }
}

var appModule = angular.module("SuperHero", []);
appModule.component("superMan", () => Application.Components.superMan);

这里的小提琴:http : //jsfiddle.net/589301uo/2/

Aleksey L.

组件定义采用配置对象,而不是函数。因此,在您的示例中,您应该使用new Application.Components.superMan()而不是() => Application.Components.superMan

还请注意,在angular 1.5中添加了组件,并且您的小提琴使用了较旧的版本。

这是工作演示。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章