NgInject compiler and closures

I try to compile the following code in ADVANCED mode unsuccessfully:

/**
 * @description App configuration
 * @param {!angular.$routeProvider} $routeProvider
 * @constructor
 * @ngInject
 */
function Config ($routeProvider) {
    $routeProvider
        .when('/', {
            templateUrl: 'mainpage/mainpage.html',
            controller: 'MainpageCtrl'
        })
        .when('/viewer', {
            templateUrl: 'viewer/viewer.html',
            controller: 'ViewerCtrl'
        })
        .otherwise({
            redirectTo: '/'
        });
}

Is there a special flag to enable?

If I add the following line, it works, but I would like to use ngInect.

Config['$inject'] = ['$routeProvider'];

thank

+4
source share
2 answers

The close compiler should start with the flag --angular_pass.

+3
source

I decided like this:

var app = angular.module("myApp", ['ngRoute']);
app.config(['$routeProvider', Config]);

I am using typescript ...

0
source

Source: https://habr.com/ru/post/1538444/


All Articles