【问题标题】:Karma ng-html2js preprocessor not generating modulesKarma ng-html2js 预处理器不生成模块
【发布时间】:2016-01-16 00:55:13
【问题描述】:

我正在尝试调试我的业力设置如何没有预处理我的指令模板。

我希望通过设置 moduleName: foo 我可以轻松地在 Chrome 调试控制台中获取模块并查看发生了什么,但是在调试中尝试 angular.module('foo') 会返回 no module found 错误,这让我相信问题出在其他地方。

我还尝试将 html 预处理器更改为一些无意义的字符串,希望 karma 会引发错误,但事实并非如此。这使我认为问题可能在于我的模板没有正确的路径,但如果我将该路径更改为其他路径,它确实会引发错误no files match this path

我是否缺少任何调试选项/方法?有没有办法记录 ng-html2js 的输入/输出?

这是我的karma.conf.js

module.exports = function(config) {
  config.set({
    plugins: [
      // these plugins will be require() by Karma
      'ng-html2js',
      'jasmine',
      'karma-jasmine',
      'karma-phantomjs-launcher',
      'karma-chrome-launcher'
    ],
    basePath: '',
    // frameworks to use
    frameworks: ['jasmine'],
    files: [
      APPLICATION_SPEC,
      '../app/assets/javascripts/image-crop.js',
      '../app/assets/javascripts/angular/**/*.js',
      '../spec/javascripts/**/*_spec.js',
      "../public/templates/**/*.html"
    ],
    exclude: [
      './app/bower_components/angular/angular.min.js'
    ],
    reporters: ['progress'],
    preprocessors: {
      '**/*.html': ['ng-html2js']
    },
    ngHtml2JsPreprocessor: {
      stripPrefix: 'public/templates',
      moduleName: 'foo',
    },
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,


    browsers: ['PhantomJS', 'Chrome'],
    singleRun: false
  });
};

【问题讨论】:

    标签: angularjs


    【解决方案1】:

    我是否缺少任何调试选项/方法?有没有 记录 ng-html2js 输入/输出的方法?

    是的; karma start --log-level debug 将显示 DEBUG [preprocessor.html2js] 条目。但是,只有在 files 路径和 preprocessors 模式正确时,您才能获得这些条目。

    【讨论】:

      【解决方案2】:

      这似乎是路径问题,因为当我将基本路径 basePath: '../' 添加到我的 karma 配置并调整我的 files: 路径时,预处理器工作正常。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-10-22
        • 1970-01-01
        • 2016-12-27
        • 2014-11-19
        • 1970-01-01
        • 2013-10-04
        • 1970-01-01
        相关资源
        最近更新 更多