firexion
firexion

Reputation: 99

Unable to instantiate module on production

I just pushed my program onto heroku and the page I had testing angular loaded with the following error:

Uncaught Error: [$injector:modulerr] Failed to instantiate module diceAngularApp due to: Error: [$injector:unpr] Unknown provider: t

It was working perfectly fine in development so I'm not sure what the problem could be. To see the error you can visit the page at www.firexion.com/dice

I'm not sure exactly where the problem could be located so I'm not sure exactly which code to share. Here's the link to the github for it: https://github.com/Firexion/hundred

My guess is it could be in the angular app.js maybe?:

'use strict';

angular
.module('diceAngularApp', [
'ngCookies',
'ngResource',
'ngSanitize',
'ngRoute'
])
.config(function ($routeProvider) {
$routeProvider
  .when('/dice', {
    templateUrl: '../../views/dice/main.html',
    controller: 'DiceController'
  })
  .otherwise({
    redirectTo: '/dice'
  });
});

or maybe I included it wrong in my rails application javascript file, lumen.js:

// Lumen
// Bootswatch
//= require jquery-2.1.0
//= require jquery_ujs
//= require lumen/loader
//= require lumen/bootswatch

// angular
//= require angular/angular
//= require angular/angular-cookies
//= require angular/angular-resource
//= require angular/angular-route
//= require angular/angular-sanitize
//= require angular/angular-scenario

// dice
//= require dice/app.js
//= require dice/controllers/main.js
//= require dice/dice.js

Thank you for whatever help you can provide.

Upvotes: 3

Views: 2009

Answers (1)

eb80
eb80

Reputation: 4738

My strong suspicion, based upon the fact that Angular is looking for a provider for the variable t and I am guessing you would not name a service/controller/etc. t is that you're using minification/compiler somewhere that is clobbering your variables.

To get around this and be safe with a compiler, you need to adjust your syntax. Full details here but the skinny is below.

myapp.config(['$routeProvider', function($routeProvider) {
  $routeProvider.when('hello/:queryId', {
    templateUrl: 'mypartial.html',
    controller: MyCtrl,
    controllerAs: 'myCtrl',
    resolve: {
      'myParam': ['myService', '$route', function(myService, $route) {
        return myService.get($route.current.params.queryId);
      }]
    }
  });

Upvotes: 7

Related Questions