2017-12-19 1 views
3

저는 ES6, Webpack 및 AngularJS 구성 요소 기반 아키텍처를 사용하여 초보자 용 상용구를 만들려고합니다. 나는 내 응용 프로그램 디렉토리가 있고 그 안에 내가 응용 프로그램 모듈을 내 보냅니다하는 index.js이있다 : AngularJS 1.6. component template URL

import { AppComponent } from './ng/app.component.js'; 

export default angular 
    .module('appModule',[]) 
    .component('app', AppComponent) 

뿐만 아니라 두 개의 다른 디렉토리 htmls에 대한 JS 파일에 대한 ngtemplates

. 나는 다음과 같은 오류 얻을이 방법을 사용

export const AppComponent = { 
    templateUrl: '../templates/app.html', 
    controller: class AppController { 
     constructor() { 
      this.title = "App Page"; 
     } 
    } 
} 

: app.component.js 내부

는 그래서 같은 .html 파일을 포함하는 트링있어

GET http://localhost:8080/templates/app.html 404 (Not Found) 

을하지만 때 나는 전체 경로를 입력 파일 src/app/templates/app.html 또는 template: require('../templates/app.html') 예상대로 작동합니다.

필요로하는 전체 경로를 입력하지 않고도 templateUrl 작업을 수행 할 수있는 방법이 있습니까?

+0

'../ templates/app.html'는 구성 요소의'.ts' 파일 (주 파일이 아님)? –

+0

@AdrienBrunelat 예. –

답변

0

나는 또한 시도 할 것이다 예를 들어 templateUrl: CONFIG.baseUrl +'/templates/app.html'

를 세션 상수를 사용하여 코드를 추가하는 방법을 보았다 templateUrl: ../../templates/app.html'

관련 문제