0

I'm working on a web application using AngularJS. Everything seemed to work well until I tried to run it with Microsoft Edge web-browser:

Error: [$injector:unpr] Unknown provider: serviceAjaxProvider <- serviceAjax <- MainCtrl

I created a service, called serviceAjax and never had any problem with it on Chrome or Firefox. But now that I'm trying to use my app on Edge I got this error.

My service is declared as the following :

serviceAjax.js

angular.module('myApp')
.service('serviceAjax', ['$http', function ($http) {
 ...
}]);

And I call it like this in my controller :

main.js

angular.module('myApp')
.controller('MainCtrl', function ($scope,serviceAjax) {
 ...
});

Where does this error come from, and how can I fix it ?

TylerH
  • 20,799
  • 66
  • 75
  • 101

2 Answers2

2

Add this:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
Karan
  • 1,048
  • 2
  • 20
  • 38
-1

Okay, I found out why it didn't work :

In fact it seems that IE doesn't understand everything written in ES6.

I used a ES6 Default Parameter :

function(var = value) {...};

So avoid using ES6 :)

(I also had compability problems with ES6 & Firefox)

  • 2
    There are other options rather than 'avoid using ES6'. You can run your ES6 code through a transform (like [babel](https://babeljs.io/)) to make it ES5 compliant. Then when browsers get their act together turn of the transform. That way you dont sacrifice the awesome that is ES6. – ste2425 Apr 12 '16 at 10:24