【发布时间】:2017-01-02 23:25:12
【问题描述】:
我的配置如下,我想为组件使用相对路径。但它给了我这个错误:
404 获取 /js/some.component.html
我正在使用 SystemJS。
some.component.ts
import { Component, OnInit } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'relative-path',
templateUrl: 'some.component.html',
styleUrls: ['some.component.css'],
})
export class SomeRelativeComponent {
}
app.component.ts
import { Component } from '@angular/core';
import { SomeRelativeComponent } from './some.component';
@Component({
selector: 'my-app',
template: `<h1>My First Angular 2 App</h1>
<relative-path></relative-path>
`,
directives: [SomeRelativeComponent]
})
export class AppComponent { }
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "./js"
}
}
文件夹结构:
/js 目录下显然没有 some.component.html。但是,当我在 /app 目录中添加我的组件时,如何将其保存在那里?
【问题讨论】:
标签: angular typescript systemjs