ottz0
ottz0

Reputation: 2605

Minify App module

I'm using uglify to minify my angular files. Where do I use the $inject method in my app.js file?

(function(){
    var myApp = angular.module('myApp',['ngRoute']);
    myApp.config(function ($routeProvider){
    $routeProvider  
        .when('/',
        {
            controller: 'HotelsController',
            templateUrl: 'js/views/hotels.html'
        })
        .when('/hotel/:hotelId',
        {
            controller: 'HotelController',
            templateUrl: 'js/views/hotel.html'
        })
    .otherwise({ redirectTo: '/' });
})
})();

Upvotes: 0

Views: 87

Answers (1)

xSaber
xSaber

Reputation: 384

I think you mean how to remain injectables in minification using $inject? If yes, then:

(function(){
    var myApp = angular.module('myApp',['ngRoute']);
    myApp.config(configFunction);

    function configFunction ($routeProvider) {
        $routeProvider  
            .when('/',
            {
                controller: 'HotelsController',
                templateUrl: 'js/views/hotels.html'
            })
            .when('/hotel/:hotelId',
            {
                controller: 'HotelController',
                templateUrl: 'js/views/hotel.html'
            })
        .otherwise({ redirectTo: '/' });
    }

    configFunction.$inject = ['$routeProvider'];

})();

Upvotes: 1

Related Questions