javascript - Include an angular template in another using webpack -
i have issue using angular , webpack. project composed of multiples views controllers.
for example, have view usersummary.tmpl.html
load list of users. reuse template in groupsummary.tmpl.html
display users too.
i can't use ng-include because views contained in bundle.js, nothing else. use webpack include views directly in another.
is possible?
to enable must configure "relativeto" parameter, otherwise template partials loaded @ "/home/username/path/to/project/path/to/template/" (check bundle.js you're leaking username in projects)
var ngtemplateloader = ( 'ngtemplate?relativeto=' + path.resolve(__dirname, './src/') + '!html' ); module.exports = { ... module: { loaders: [ {test: /\.html$/, loader: ngtemplateloader}, ], }, ... }
then in code, side-effect require:
// src/webapp/admin/js/foo.js require('../../templates/path/to/template.html');
then can load html:
<div ng-include src="'/webapp/templates/path/to/template.html'"</div>
Comments
Post a Comment