使用SystemJS在组件中使用templateUrl的相对路径 [英] Using relative path for templateUrl in Component with SystemJS

查看:88
本文介绍了使用SystemJS在组件中使用templateUrl的相对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在angular2组件中定义templateUrl时使用相对路径,如下所述: http://schwarty.com/2015/12/22/angular2-relative-paths-for-templateurl-and-styleurls/

I'm trying to use relative path when defining templateUrl in angular2 component, as described here: http://schwarty.com/2015/12/22/angular2-relative-paths-for-templateurl-and-styleurls/

@Component({
    selector: 'login-app',
    moduleId: module.id,
    templateUrl: './app.html'
})

尽管我不断得到:

错误:模块未定义

ERROR: module is not defined

我在TypeScripy编译设置中使用--m commonjs.

I am using --m commonjs in TypeScripy compile settings.

如何使其工作?

推荐答案

这似乎对我不起作用. 我可以在Github存储库中看到Angular 2,该功能应该在12月初添加,但是并没有.我完全可以说出这个功能.

This simply doesn't seem to work for me. I can see in the Github repo for Angular 2 that the feature was supposedly added in early December, but it doesn't function at all best I can tell.

文档尚未更新以反映出来,据我所知,它仍缺少适当的测试.

The docs have not been updated to reflect it, and it's still missing proper tests from what I can tell.

更新:

这是正在发生的事情的一部分. 这需要CommonJS特定的功能才能正常工作,因此您必须在使用该模块系统您的tsconfig.json文件.

Here's part of what's going on. This requires a CommonJS specific feature to work, so you have to have that module system in use in your tsconfig.json file.

最重要的是,使用SystemJS时存在问题,因为它的捆绑方式一切都扎根了.

On top of that, there's an issue when using SystemJS because of the way it bundles everything into the root.

基本上,在使用此新功能方面似乎有很多限制.

Basically there seem to be a lot of restrictions on being able to use this new feature.

这篇关于使用SystemJS在组件中使用templateUrl的相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆