Angular 2最终发行版Visual Studio-无法对模块,module.id进行命名,传递错误的路径/导致404 [英] Angular 2 Final Release Visual Studio - cannot fine name module, module.id passing incorrect path/causing 404

查看:130
本文介绍了Angular 2最终发行版Visual Studio-无法对模块,module.id进行命名,传递错误的路径/导致404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚升级到Angular 2 Final Release(我正在使用Visual Studio 2015和TypeScript 1.8),并且注意到我组件中的行 moduleId:module.id 现在带有红色的波浪下划线并说找不到名称模块" .

I just upgraded to the Angular 2 Final Release (I am using Visual Studio 2015 and TypeScript 1.8) and noticed my line moduleId: module.id in my components now has the red squiggly underline and say cannot find name 'module'.

在Chrome的网络标签中,我看到 templateUrl styleUrls 路径都不正确.

In the network tab in Chrome I see that the templateUrl and styleUrls paths are both incorrect.

这是我的工作组件:

@Component({
    selector: 'dashboard',
    moduleId: module.id,
    templateUrl: 'dashboard.component.html',
    styleUrls: ['dashboard.component.css'],
    styles: ['.chart {display: block; width: 100%;} .title.handle{background-color:transparent;}']

})

**但是当我删除行 moduleId:module.id 时,由于出现了以下错误,我收到404错误:

**But when I remove the line moduleId: module.id I get a 404 error because it is looking for:

http://localhost:56159/dashboard.component.css http://localhost:56159/dashboard.component.html

任何帮助将不胜感激!

谢谢

推荐答案

尝试一下,为这两个文件路径赋予它们 ./的路径

try this, giving those two files paths these ./ in front of them

@Component({
    selector: 'dashboard',
    templateUrl: './dashboard.component.html',
    styleUrls: ['./dashboard.component.css'],
    styles: ['.chart {display: block; width: 100%;} .title.handle{background-color:transparent;}']

})

这篇关于Angular 2最终发行版Visual Studio-无法对模块,module.id进行命名,传递错误的路径/导致404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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