Currently, I am facing an issue where I need to set the
templateUrl: "partials/my-directive.html"
However, I find that I have to use
templateUrl: "app/partials/my-directive.html
for it to be loaded by Karma.
This is how my folder structure looks like (following a typical Yeoman setup)
app
partials
my-directive.template.html
directives
my-directive.js
app.js
karma.conf.js
Below is the directive implementation in code.
angular.module("exampleApp")
.directive("adminMod", function () {
return {
restrict: "E",
templateUrl: "app/partials/admin-mod.html",
scope: {
props: "="
}
}
});
Here's a snippet of the unit test.
beforeEach(module("app/partials/admin-mod.html"));
And here's the relevant part from karma.conf.js file.
files: [
'app/bower_components/jquery/jquery.js',
'app/bower_components/angular/angular.js',
'app/partials/*.html'
],
preprocessors: {
'app/partials/*.html': 'ng-html2js'
},
ngHtml2JsPreprocessor: {
//prependPrefix: ???? what do I make this
},
I aim to make the URL relative to the app folder rather than my karma.conf.file. I've tried various path combinations but haven't found a solution yet. Can someone shed some light on how this should ideally work with a Yeoman generated Angular file structure?