建立NG-htmljs- preprocessor人缘preprocessor [英] setting up ng-htmljs-preprocessor karma preprocessor
问题描述
我设立我噶配置文件,但我不完全了解一些选项存在,因为我没有成功测试已通过ngHtml2Js preprocessor跑,并已模板
I am setting up my Karma configuration file, but I do not fully understand some of options that exist as I am not having success testing templates that have ran through the ngHtml2JsPreprocessor and have been
$templateCached
在ngHtml2Js preprocessor的,我可以添加路径涉及几个关键值的属性。
Inside of the ngHtml2JsPreprocessor I can add a few key value properties involving paths.
ngHtml2JsPreprocessor: {
stripPrefix: ".*/Went all the way back to the root of my application/",
// moduleName: 'templatesCached'//
},
我现在注释掉的模板,以确保我收到访问每个文件模块。我加载,没有错误的模块。我可以在我的开发工具找到templateCached版本。
I commented out the templates for now to make sure that I am getting access to each file as module. I am loading the modules with no error. I can find the templateCached version in my dev tools.
beforeEach(module('template'));
我的模板文件夹坐在我创造了基本路径之外。
My Templates folder sits outside the basepath I created.
basePath: 'Scripts/',
我这里面引用在 preprocessors 的对象
preprocessors: {
'../Templates/**/*.html' : ['ng-html2js']
},
此外我所有的模板是现在js文件和缓存。
Again all of my templates are now js files and cached.
我在我的里面的package.json 我保存的文件为
I inside of my package.json I saved the files as
save-dev
"karma-chrome-launcher": "^0.2.2",
"karma-jasmine": "^0.2.2",
"karma-ng-html2js-preprocessor": "^0.2.1",
我引用我在安装插件。
I referenced my installs in the plugins.
plugins: [
'karma-chrome-launcher',
'karma-jasmine',
'karma-sinon',
'karma-ng-html2js-preprocessor'
],
我有我的所有文件加载
I have all of my files loaded
files: [
//jquery libaries
// angular libraries
// Scripts files
// source app.js
// tests folder and files
]
我的测试流失噶启动
My tests are running off of Karma start
不过,我的指令只是一个空字符串
However, my directive is just an empty string
element.html()
返回
我已经诗人注射建立
bard.inject(
"$compile",
"$controller",
"$rootScope",
'$templateCache',
"haConfig",
"$q"
);
下面是我的beforeEach
Here is the inside of my beforeEach
bard.mockService(haConfig, {
getTemplateUrl: '/briebug-sucks!'
});
//bard.mockService(haConfig, {});
console.log('ha config2', haConfig.getTemplateUrl());
var html = angular.element("<div explore-hero></div>");
console.log('htl',haConfig.getTemplateUrl());
scope = $rootScope.$new();
//templateCache
element = $compile(html)(scope);
//console.log(haConfig.getTemplateUrl(html));
scope.$digest(element);
console.log('missing text',haConfig.getTemplateUrl(html));
controller = element.scope();
console.log("element", element);
我不知道为什么我收到一个空字符串返回。我创建的HTML文件,但没有什么是它的内部。
I have no idea why I am getting an empty string back. I am creating the html file but, nothing is inside of it.
我能不知道是否我应该在的templatesCached文件的出现在我的开发工具的文件夹中吗?也不论是否在文件应该里面的文件阵列的内部被引用的 karma.conf.js 的
All I can wonder if I should have the the templatesCached files showing up in a folder on my dev tools? Also whether or not the files should be referenced inside of the files array inside karma.conf.js
现在我有HTML文件中引用?我已经试过了js文件,但似乎并没有做任何事情。
Right now I have the html files referenced? I have tried the js files but that did not seem to do anything
推荐答案
这个问题实际上是很简单的修复。我很想把它删除,但万一有人也有类似的问题,我想这是可用的。
The problem was actually quite simple fix. I was tempted to delete it but, in case someone has a similar issue I want this to be available.
我有一个在karma.conf.js内幕
Inside the karma.conf.js I have a
stripPrefix: 'rootDirectory' // was already in place
stripSuffix: '.js.html' // I had to make a strip on the templatesCached
prependSuffix: '.html' // this is what I was searching for
当preprocessor跑了templateCached我的所有文件。然而,他们并没有就此结束,我期待他们的方式,我无法阅读。我有模块等部位设置正确。
When the preprocessor ran it templateCached all of my files. However, they did not end the way that I was expecting them and I could not read them. I had the module and other parts set up correctly.
这篇关于建立NG-htmljs- preprocessor人缘preprocessor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!