Closed wembernard closed 8 years ago
Hi, thanks for following the issue template @wembernard External template with Angular 2 will be part of the next release, the code is already on master. Meanwhile here are the steps you need to go through with angular2/webpack:
template = require('relative/path/to/template.html')
moduleId: __moduleName
in @Component({...})
at last, you need to install and set up the Webpack html loader
conf/webpack-*.conf.js
you have to add the following into module.loaders
array{
test: /.html$/,
loaders: [
'html'
]
}
npm install html-loader --save-dev
All this will be in next release in few days 😉
Description
I'm going with the following file structure:
But when I want to use
templateUrl: 'app.component.html'
in myapp.component.ts
I get the following Error Message & Stack Trace (see below).I succeeded to fix the problem by writing the full relative path:
./app/app.component.html
but this is bad and when my app will grow (and it will grow pretty fast), moving components in subfolders will be a real pain.In Angular Style guide, they suggest just to use
templatename.html
instead of./relativepath/templatename.html
but this does not work for me. Have you tried? Is it related to Webpack? Should I switch to SystemJS instead?By the way, I suggest your generator to use
templateUrl
in one of your samples (todoMVC for example?) as a best practice 👍Error Message & Stack Trace
Config
Content from
.yo-rc.json
:Environment