WearyMonkey / ngtemplate-loader

Include AngularJS templates in the Webpack bundle and preload the template cache.
MIT License
238 stars 78 forks source link

ng-include relativeTo prefix slash #75

Closed SamanthaAdrichem closed 5 years ago

SamanthaAdrichem commented 7 years ago

We've been using angular for quite a while now, and have always included templates from the app/root director like this

file is at app/pages/page/template.html templateUrl: 'pages/page/template.html'

your plugin however adds a / infront of it.

Now with the default require, that is not an issue, because we use it like var templateUrl = require("pages/page/template.html") templateUrl: templateUrl.

However in case of ng-include we do require("path/file.html"); ng-include src="'path/file.html'" (does not support an angular variable...

and then it says template not found, for the template suddenly has been registered with a prefixed /

the template loader is included as:

'ngtemplate-loader?relativeTo=' + (path.resolve(__dirname, './app')),

how do we remove this prefixed /??

pjparra commented 6 years ago

Hi, I struggled quite a bit with this loader (but I'm also new to webpack, so a lot of my struggles were just webpack related).

Did you try something like this? 'ngtemplate-loader?relativeTo=' + (path.resolve(__dirname, './app')) + '/'

I just had a similar problem, and adding the trailing / to the relativeTo option fixed it.

SamanthaAdrichem commented 6 years ago

Will try that tomorrow! Thnx

activedecay commented 5 years ago

you lifesaver @pjparra

pjparra commented 5 years ago

Glad this solution works for you too :smile:

SamanthaAdrichem commented 5 years ago

I never closed this. So sorry. It worked for us too! Thnx again!

dingzhanjun commented 4 years ago

@pjparra saved my day, thanks!