Sunday, March 29, 2015

Unexpected request GET error in Angular JS

I got the
Error: Unexpected request: GET components/template.html
No more request expected
at $httpBackend ... 

For me, the reason for this problem is:
The relative path of template.html in karma.conf.js preprocessors, beforeEach(module) and myDirective.js are different, i.e:
in the karma.conf.js, it was:
preprocessors: {
    'src/components/template.html': ['ng-html2js']
},

in the beforeEach(module), it was:

beforeEach(module('src/components/template.html'))

and in the myDirective,js, it was:

function myDirective(){
    return{
        restrict: 'EA',
        templateUrl: 'src/components/template.html'
    };
}

To solve the problem, I change all the relative path to
'src/components/template.html'

No comments:

Post a Comment