2016-02-26 73 views
0

我正在使用uglify缩小我的角度文件。我在哪里可以在我的app.js文件中使用$inject方法?缩小应用程序模块

(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: '/' }); 
}) 
})(); 
+0

myApp.config(函数($ routeProvider,$注射){} – Prasad

+0

https://www.youtube.com/watch?v=f86bSPXdw20缩小视频 – Prasad

回答

1

我认为你的意思是如何保持使用$ inject的缩小注射剂? 如果是,则:

(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']; 

})();