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

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

问题描述

我想在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'
})

虽然我不断收到:

although I keep getting:

错误:模块没有定义

我使用--m CommonJS的TS上编译设置。

I am using --m commonjs on ts compile settings.

如何使它工作?

推荐答案

这只是似乎并没有为我工作。 我可以在角2 GitHub的回购看到该功能是在十二月初理应增加,但它不工作在所有最好的,我可以告诉。

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.

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

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