Edg*_*nez 10 javascript angularjs karma-runner ng-html2js
我遇到的问题是我想做的 templateUrl: "partials/my-directive.html"
但目前我必须制作它templateUrl: "app/partials/my-directive.html以便由Karma加载.
这是我的文件夹结构(基本上是yeoman文件夹结构)
app
partials
my-directive.template.html
directives
my-directive.js
app.js
karma.conf.js
Run Code Online (Sandbox Code Playgroud)
这是指令代码
angular.module("exampleApp")
.directive("adminMod", function () {
return {
restrict: "E",
templateUrl: "app/partials/admin-mod.html",
scope: {
props: "="
}
}
});
Run Code Online (Sandbox Code Playgroud)
继承单元测试部分
beforeEach(module("app/partials/admin-mod.html"));
Run Code Online (Sandbox Code Playgroud)
继承人karma.conf.js
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
},
Run Code Online (Sandbox Code Playgroud)
我想制作相对于app文件夹的url而不是我的karma.conf.file我想我已经用尽了路径的每一个组合,有人可以解释这是什么以及如何使用Yeoman角度生成器文件结构
Edg*_*nez 19
问题是我试图使用
ngHtml2JsPreprocessor: {
prependPrefix: ???? what do I make this
},
Run Code Online (Sandbox Code Playgroud)
但我真正应该使用的是
ngHtml2JsPreprocessor: {
stripPrefix: 'app/',
},
Run Code Online (Sandbox Code Playgroud)
然后,我可以保持相对于app/文件夹的路径,并在单元测试中将模板作为这样的模型
beforeEach(module("partials/admin-mod.html"));
Run Code Online (Sandbox Code Playgroud)
这是我指令中的相同路径
templateUrl: "partials/admin-mod.html",
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6959 次 |
| 最近记录: |