更新时间:2023-02-11 19:07:39
为使您必须配置对于relativeTo参数,否则您的模板谐音得到在/家庭/用户名/路径/要/项目/路径加载/到/模板/(检查bundle.js你可能泄露您的用户名在您的项目)
To enable you must to configure the "relativeTo" parameter, otherwise your template partials get loaded at "/home/username/path/to/project/path/to/template/" (Check your bundle.js you're probably leaking your username in your projects)
var ngTemplateLoader = (
'ngtemplate?relativeTo=' + path.resolve(__dirname, './src/') +
'!html'
);
module.exports = {
...
module: {
loaders: [
{test: /\.html$/, loader: ngTemplateLoader},
],
},
...
}
然后在你的code,做一个副作用只需要:
Then in your code, do a side-effect only require:
// src/webapp/admin/js/foo.js
require('../../templates/path/to/template.html');
然后就可以加载HTML:
Then you can load the html:
<div ng-include src="'/webapp/templates/path/to/template.html'"</div>