首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ng-html2js不适用于幻影,而适用于Chrome。

ng-html2js不适用于幻影,而适用于Chrome。
EN

Stack Overflow用户
提问于 2014-10-31 20:16:14
回答 1查看 441关注 0票数 2

我在用cg-角钢作为我的项目的支架。

我正在测试一个使用templateUr和ng-html2js将模板加载到模块中的指令。当我使用Chrome作为浏览器运行我的测试时,它没有问题,但是当我使用Phantom运行它时,我得到:

代码语言:javascript
复制
Error: [$injector:modulerr] Failed to instantiate module templates due to:

下面是我的Gruntfile的相关部分:

代码语言:javascript
复制
karma:      {
     options:     {
         frameworks:           ['jasmine'],
         preprocessors:        {'directive/**/*.html':['ng-html2js']},
         files:                [  //this files data is also updated in the watch handler, if updated change there too
             '<%= dom_munger.data.appjs %>',
             'bower_components/angular-mocks/angular-mocks.js',
             'directive/**/*.html',
             createFolderGlobs(['*-spec.js'])
         ],
         ngHtml2JsPreprocessor:{
             moduleName:'templates'
         },
         logLevel:             'ERROR',
         reporters:            ['mocha'],
         autoWatch:            false, //watching is handled by grunt-contrib-watch
     },
     all_tests:   {
         browsers: ['PhantomJS', 'Chrome'],
         singleRun:false
     },
     during_watch:{
         browsers: ['PhantomJS'],
         singleRun:true
     }
 }

因此,运行运行karma:all_tests的咕噜测试,工作起来就像一个冠军。运行karma:during_watch的咕噜发球失败。

是否有一种方法来检查html2js是否实际正在运行?

编辑这不是幻影。如果我在“during_watch”任务中运行Chrome,它也会失败。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-03 15:18:51

弄明白了。我用发电机-cg-角钢支架这个项目。它使用咕噜表事件来设置一些选项。此事件仅在服务任务中使用,而不是在测试或生成期间使用。我没有注意到它正在覆盖karma.options,因此html2js从未被调用过。当我将其附加到Gruntfile的事件部分时,html2js将按应有的方式运行。下面是显示更改的Gruntfile的相关部分。

代码语言:javascript
复制
if (grunt.file.exists(spec)) {
    var files = [].concat(grunt.config('dom_munger.data.appjs'));
    files.push('bower_components/angular-mocks/angular-mocks.js');
    files.push(spec);
    files.push('directive/**/*.html'); // This one
    grunt.config('karma.options.files', files);
    grunt.config('karma.options.ngHtml2JsPreprocessor.moduleName', 'templates'); // And this one
    tasksToRun.push('karma:during_watch');
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26682740

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档