ngtemplate-loader
ngtemplate-loader copied to clipboard
ngtemplate-loader generated code `path` variable refers to the absolute path.
Hello team,
I am using the ngtemplate-loader
and everything works quite fine as expected, as far as I have tested. though I am finding a bit of problem in the code generated after running the webpack command.
This is how I am loading the template
var patietProfileTemplate = require('ngtemplate-loader!../views/patientProfile.html');
This is how the generated code looks like for the template caching:
var path = '/Users/mritunjd/Documents/projects/bahmni/bahmniapps-commons/patient-profile/views/patientProfile.html';
var html = "<div>\n Some content</div>";
window.angular.module('ng').run(['$templateCache', function(c) { c.put(path, html) }]);
module.exports = path;
Now the value of variable path
is absolute file location on my disc. Though I tested this on my vagrant
machine and it works fine, so doesn't look like it is actually reading from that path.
My question is why does it refer to absolute path and how to get rid of that. It gives an impression that it will work only in my machine. Let me know if I have missed something.
path
is just key in memory so don't worry. c.put
is actually $templateCache.put
.
Check here https://docs.angularjs.org/api/ng/service/$templateCache.