2016-10-20 2 views
1

tsconfig.json에서 모든 .map 및 .js 파일을 출력 폴더에 저장하려면 my compilerOptions를 다음과 같이 설정해야합니다.각도 2 module.id

{ 
    "compilerOptions": { 
    "target": "es5", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "noImplicitAny": false, 
    "outDir": "./app/output" 
    } 
} 

system.config.js에서 main.js를로드하기 위해 아래 패키지를 구성했습니다.

packages: { 
     app: { 
     main: './output/main.js', 
     defaultExtension: 'js' 
     }, 
     rxjs: { 
     defaultExtension: 'js' 
     }, 
     'angular-in-memory-web-api': { 
     main: './index.js', 
     defaultExtension: 'js' 
     } 
    } 

여기 내 app.component.ts

import { Component } from '@angular/core'; 

@Component({ 
    moduleId:module.id, 
    selector: 'my-app', 
    templateUrl: 'app.html' 
}) 
export class AppComponent { } 

내가이 module.id가 로컬 호스트와 같은 경로를 얻을 것이다 왜 프로젝트를로드 할 때 질문은 : 3000/응용 프로그램/출력/localhost : 3000/app/app.html 대신 app.html을 사용하십시오. 그것은 내가 HTML을로드하는 데 오류가 발생했습니다. module.id는 index.html과 관련된 루트 경로를 가져야합니다.

이미지 아래에 index.html 파일에서

enter image description here

답변

1

Angular2 router 문서에 따라

<base href="/"> 

을 추가 내 프로젝트의 트리 구조를 보여줍니다.