There is a way to require html file in javascript file like webpack does with gulp?
For example in Angular js directive:
return {
template: require('./../index.html),
link : function() {}
}
There is a way to require html file in javascript file like webpack does with gulp?
For example in Angular js directive:
return {
template: require('./../index.html),
link : function() {}
}
No, angularjs is a client-side framework that is meant to run in a browser. Within a browser you generally speaking are not meant to be reading local files even if the purpose is just for including/requiring files.
Webpack is actually a node module (npm) that runs under nodejs. The require
method is added by nodejs and allows you to load other javascript files. However, nodejs modules are always run by nodejs and never in the browser.
Having said that, there might be solutions to achieve what you want, here is one discussion of a similar issue.