私は、ES6、Webpack、AngularJSコンポーネントベースのアーキテクチャを使用して、スターターの定型文を作成しようとしています。私は私のアプリのディレクトリを持っており、その中に私がアプリモジュールをエクスポートするindex.jsがあります: AngularJS 1.6。コンポーネントtemplateUrl
import { AppComponent } from './ng/app.component.js';
export default angular
.module('appModule',[])
.component('app', AppComponent)
だけでなく、他の二つのディレクトリHTMLSためのjsファイル用ng
とtemplates
app.component.js
インサイド
私はそうのような.htmlのファイルをインクルードするトリングだ:
export const AppComponent = {
templateUrl: '../templates/app.html',
controller: class AppController {
constructor() {
this.title = "App Page";
}
}
}
をこのメソッドを使用して、私は次のエラーを取得する:
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はい。 –