0

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: '/' }); }) })(); 
2
  • myApp.config(function ($routeProvider,$inject){} Commented Feb 26, 2016 at 4:36
  • youtube.com/watch?v=f86bSPXdw20 minification video Commented Feb 26, 2016 at 4:44

1 Answer 1

1

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']; })(); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.