Agent Zebra
Agent Zebra

Reputation: 4550

Angular js minify errors

When I try to minify the following code it breaks. What's wrong? What's the simplest way to fix this?

(function () {
    'use strict';
    angular.module('weatherapp.weatherlist')
    .controller('WeatherlistController2', function($scope, utcFactory) { 
        var vm = this; 
        vm.utc = utcFactory.myUTC(); 
     })

    .factory('utcFactory', function() {
        var myUTC = function() {
          var offset = -new Date().getTimezoneOffset();
          var utc = ((offset > 0 ? '+' : '') + offset / 60);
          return utc;
        }

        return {
          myUTC: myUTC
        }
    });
})();

Upvotes: 0

Views: 50

Answers (1)

AJ Meyghani
AJ Meyghani

Reputation: 4609

This is a common problem. Use the array syntax for your controller:

.controller('WeatherlistController2', [ '$scope', 'utcFactory', function($scope, utcFactory) {}])

See here as well: Angularjs minify best practice

Upvotes: 1

Related Questions