cnak2 cnak2 - 1 month ago 17
AngularJS Question

How do you wrap a uibModal controller in brackets to protect it from minifying

I have a modal function that is having a problem when I minify. It's because the controller isn't wrapped in brackets.

With a regular controller, I would use " .controller('Ctrl', ['$scope', function($scope){});

But with my modal, it just calls a straight function:

var modalInstance = $uibModal.open({
animation: true,
backdrop: 'static',
keyboard: false,
templateUrl: 'questionsModal.html',
controller: function($scope, $uibModalInstance, SweetAlert) {


I tried the following:

var modalInstance = $uibModal.open({
animation: true,
backdrop: 'static',
keyboard: false,
templateUrl: 'questionsModal.html',
controller: ('', [ '$scope', function($scope) {}])


But it doesn't work.

Answer

Here you go:

 var modalInstance = $uibModal.open({
                animation: true,
                backdrop: 'static',
                keyboard: false,
                templateUrl: 'questionsModal.html',
                controller: ['$scope', '$uibModalInstance', 'SweetAlert', function($scope, $uibModalInstance, SweetAlert) {
                 }]