저는 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 파일에 대한 ng
및 templates
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
작업을 수행 할 수있는 방법이 있습니까?
'../ templates/app.html'는 구성 요소의'.ts' 파일 (주 파일이 아님)? –
@AdrienBrunelat 예. –