0

I wish to use ng-annotate and the following syntax in my app (using ng-strict-di) to avoid minification issues but I keep getting this error in the console as if I was missing the /** ng@Inject */ comment above the routeConfig function.

What am I missing?

This is the error:

**Uncaught Error: [$injector:modulerr] Failed to instantiate module something due to:
Error: [$injector:strictdi] routeConfig is not using explicit annotation and cannot be invoked in strict mode**

And this is the route config file.

(function () {
    'use strict';

    angular
        .module('something')
        .config(routeConfig);

    /** @ngInject */
    function routeConfig($stateProvider, $urlRouterProvider, $locationProvider) {
        $stateProvider
            .state('home', {
                url: '/',
                controller: 'MainController'
            })
            .state('properties', {
                url: '/properties',
                templateUrl: 'app/components/properties/properties.html',
                controller: 'PropertiesController',
                controllerAs: 'properties'
            })
            .state('properties.map', {
                templateUrl: 'app/components/properties-map/properties-map.html'
            })
            .state('properties.grid', {
                templateUrl: 'app/components/properties-grid/properties-grid.html'
            })
            .state('property', {
                url: '/property/:id',
                templateUrl: 'app/components/property/property.html',
                controller: 'PropertyController',
                controllerAs: 'property'
            });

        $urlRouterProvider.otherwise('/');

        $locationProvider.html5Mode(true);
    }

})();

Many thanks for your help.

Gab
  • 2,216
  • 4
  • 34
  • 61
  • Does this error also come up on your minified code? If not, then I expect that everything is working as it should. The strictdi is capturing the fact that modules are di'ed without explicitly provided dependencies. Your use of ngInject should take care of this in the minified code. Perhaps you should only use the strictdi option in your minified code, not on your dev setup. – Fridjon Gudjohnsen Oct 24 '15 at 23:28
  • Ok thanks will do that! I thought I was doing something wrong. – Gab Oct 25 '15 at 03:18

0 Answers0