Puts HTML files to Angular $templateCache.
- You can use ng-include directives with require syntax
- You will always have the content of the file in assigned variable
You can install loader using npm:
npm i angular-templatecache-loader
main.js
var myTemplate = require('./src/myTemplate.html'); // You will have your template in myTemplate variable
index.html
<div ng-include="'src/myTemplate.html'"></div>
- module - name of angular module (default is ng)
{
test: /\.html$/,
loader: "angular-templatecache-loader?module=app"
}
- prefix - add prefix to all file names
{
test: /\.html$/,
loader: "angular-templatecache-loader?prefix=/public/src"
}
- You can also use context in webpack to pass correct template url. See Context example
var app = path.join(__dirname, 'app');
module.exports = {
context: app
}