Javascript error Unknown provider: tProvider <- t after Rails minification Angularjs Javascript error Unknown provider: tProvider <- t after Rails minification Angularjs ruby-on-rails ruby-on-rails

Javascript error Unknown provider: tProvider <- t after Rails minification Angularjs


This error itself is Angular saying that it doesn't know what to inject for 't'. Which means that 't' must be a minified name for one of your injections somewhere.

If it works before minification but not after then it has to be an issue with something somewhere not using the min-safe injection method.

I'd check to make sure everything you're doing is minsafe, and also that you are not trying to minify the non-minsafe version of angular.js itself. Always use the .min that comes in the angular package rather than minifying your own (or if you do want to minify your own make sure it's the minsafe version).

Here's an example of making a controller minsafe. The following is NOT minsafe:

angular    .module('myModule')    .controller('MyCtrl', function($scope, myService) {         //your non-minsafe controller     });

To make it minsafe we encapsulate the function call in an array which begins with the things we want to inject, and ends in the function call with the same order of arguments:

angular    .module('myModule')    .controller('MyCtrl', ['$scope', 'myService', function($scope, myService) {         //your minsafe controller     }]);


I have the same problem with the gem hiravgandhi/angularjs-rails

I was able to work OFF minifcation in production by changing my settings in config/environments/production.rb

config.assets.js_compressor = Uglifier.new(mangle: false)

Using a Rails 4.0.2 app with the hiravgandhi/angularjs-rails gem as instructed by the gem installation instructions.


I had a same problem and I found out that the problem was not in .controller call, it was in .config where it was not minification safe.

before

var app = angular.module('myModule', ['restangular']);app.config(function(RestangularProvider) {    RestangularProvider.setDefaultHeaders({'Content-Type': 'application/json'});    RestangularProvider.setBaseUrl('http://myapi.com/api/v1');});

After

var app = angular.module('myModule', ['restangular']);app.config(['RestangularProvider', function(RestangularProvider) {    RestangularProvider.setDefaultHeaders({'Content-Type': 'application/json'});    RestangularProvider.setBaseUrl('http://myapi.com/api/v1');}]);