ngInject and closure compiler

ε祈祈猫儿з 提交于 2019-12-07 09:02:51

问题


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 any special flag to be turned on?

If I add the following line it works, but I would like to take advantage of ngInect.

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

Thanks


回答1:


The closure compiler needs to run with the "--angular_pass" flag.




回答2:


I solved this way :

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

I am using typescript...



来源:https://stackoverflow.com/questions/23345906/nginject-and-closure-compiler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!