pinoyyid
pinoyyid

Reputation: 22306

Why does my dialog controller fail after minification?

I have the following code which works fine un-minimised:

$scope.newContact = function(ev) {
    console.log(1);
    var d = $dialog.dialog({
        template : newcontactdialog, 
        controller : 'ContactDialogController'
     });
console.log(2);
d.open().then(function(result) {
   console.log(4);
});
console.log(3);
};

function ContactDialogController($scope, dialog) { ... etc ...}

After I minimise (closure compiler, Simple Optimizations), I get:

1
2
3
Error: Unknown provider: aProvider <- a

I guess I need to do something to protect the ContactDialogController, or perhaps it's the ($scope, dialog) function arguments, but I can't figure it out.

Is there a recommended minifier for AngularJS?

Upvotes: 1

Views: 177

Answers (1)

Foo L
Foo L

Reputation: 11137

You need to specify the controller in this format:

var PhoneListCtrl = ['$scope', '$http', function($scope, $http) { /* constructor body */ }];

Check out 'A Note on Minification' from the angular tutorial.

Upvotes: 4

Related Questions