javascript - Dependency injection error in angular -


i getting uncaught error: [$injector:modulerr] in strange manner.

if inject dependency in manner throws above error.

'use strict';  var app = angular.module('myroutes', ['ngroute']);  app.config(['$routeprovider'], function ($routeprovider) {    });  

but if flip above snippet in below way, error gone.

'use strict';  var app = angular.module('myroutes', ['ngroute']);   app.config(function ($routeprovider) {     //no error  }); 

i using angular v 1.3.1

scripts including order.

  • angular.js
  • angular-routes.js
  • myroutes.js
  • myctrl.js

considering minification in production environment, can't go second way.

you have not closed config inline array annotation function correctly

app.config(['$routeprovider'], function ($routeprovider) { 

should be

//                     vvvvvvvvvv removed  `]` app.config(['$routeprovider', function ($routeprovider) {  }]); //<-- close here 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -