AngularJS + Karma + Ng-html2js => Failed to instantiate module …html

后端 未结 4 894
深忆病人
深忆病人 2021-02-02 09:28

I can\'t make Karma working for directives that have external templates.

Here is my karma configuration file :

pr         


        
4条回答
  •  长发绾君心
    2021-02-02 10:26

    This may not be your exact issue, but in our application we needed to add the following to karma.conf.js:

    ngHtml2JsPreprocessor: {
        cacheIdFromPath: function(filepath) {
            return '/vision/assets/' + filepath;
        }
    }
    

    The corresponding preprocessors setting looks like:

    preprocessors: {
        'views/**/*.html': 'html2js'
    },
    

    My understanding was that this was due to using absolute URLs in AngularJS when specifying templates - which karma was rewriting when running tests?

    Anyway hope this helps.

提交回复
热议问题