2014-05-08 7 views
7

Nach angle-ui-Bootstrap und laufen grunt serve auf meiner Yeoman App, es läuft perfekt und die Modalität, die ich zeigen will, wird korrekt angezeigt, aber sobald ich ein Grunzen Build, bekomme ich einen unbekannten Provider Fehler in meiner Konsole.angular-ui-bootstrap verursacht unbekannten Provider Fehler bei der Minimierung

<!-- This is what I added in my index.html --> 
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script> 

// In app.js I have 
angular.module('yeomanApp', [ 
    'ngCookies', 
    'ngResource', 
    'ngSanitize', 
    'ngRoute', 
    'ui.bootstrap' 
]) 

und in der Steuerung,

.controller('myCntrl', function ($modal) { 

$scope.items = ['item1', 'item2', 'item3']; 

$scope.showDeleteWarning = function() { 
    var modalInstance = $modal.open({ 
     templateUrl: 'deleteWarning.html', 
     controller: ModalInstanceCtrl, 
     resolve: { 
      items: function() { 
       return $scope.items; 
      } 
      } 
     }); 

    modalInstance.result.then(function (selectedItem) { 
     $scope.selected = selectedItem; 
    }, function() {}); 
    }; 

// Please note that $modalInstance represents a modal window (instance) dependency. 
// It is not the same as the $modal service used above. 

var ModalInstanceCtrl = function ($scope, $modalInstance, items) { 

    $scope.items = items; 
    $scope.selected = { 
    item: $scope.items[0] 
    }; 

    $scope.ok = function() { 
    $modalInstance.close($scope.selected.item); 
    deleteVent(); 
    }; 

    $scope.cancel = function() { 
    $modalInstance.dismiss('cancel'); 
    }; 
}; 

}; 

Antwort

0

Ich weiß, dass dies eine alte Frage ist , aber ich werde meine Antwort hier für Leute veröffentlichen, die in Zukunft auf dieses Problem stoßen.

Ich stieß auf dieses genaue Problem vor. Die Ursache für Ihre Fehler bei der Minimierung ist höchstwahrscheinlich Ihre 'var ModalInstanceCtrl'.

Hier ist, wie ich meinen Code an die Arbeit:

var modalInstance = $modal.open({ 
    templateUrl: 'deleteWarning.html', 
    controller: 'ModalInstanceCtrl', //change this to a string 
    resolve: { 
     items: function() { 
      return $scope.items; 
     } 
     } 
    }); 

und diese Linie:

var ModalInstanceCtrl = function ($scope, $modalInstance, items) { 

zu:

angular.module('myModule').controller('ModalInstanceCtrl', function ($scope, $modalInstance, items) { 
0

Für alle, die dieses Problem nur begegnet, vielleicht diese wird helfen. Wir verwenden customModalDefaults und customModalOptions, so hatten wir die ganze return $modal.open(tempModalDefaults).result; in der Show-Funktion der folgenden drehen:

this.show = function (customModalDefaults, customModalOptions) { 
    //Create temp objects to work with since we're in a singleton service 
    var tempModalDefaults = {}; 
    var tempModalOptions = {}; 

    //Map angular-ui modal custom defaults to modal defaults defined in service 
    angular.extend(tempModalDefaults, modalDefaults, customModalDefaults); 

    //Map modal.html $scope custom properties to defaults defined in service 
    angular.extend(tempModalOptions, modalOptions, customModalOptions); 

    return $modal.open({ 
     backdrop: customModalDefaults.backdrop, 
     keyboard: customModalDefaults.keyboard, 
     modalFade: customModalDefaults.modalFade, 
     templateUrl: customModalDefaults.templateUrl, 
     size: customModalDefaults.size, 
     controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) { 
      $scope.modalOptions = tempModalOptions; 
      $scope.modalOptions.ok = function (result) { 
       $modalInstance.close(result); 
      }; 
      $scope.modalOptions.close = function (result) { 
       $modalInstance.dismiss('cancel'); 
      }; 
     } ] 
    }).result; 
}; 
0

ich nur in dieses Problem auf nur eine von vielen modals während meiner gesamten Anwendung verwendet lief, und es stellte sich aus meinem Problem wurde nicht explicit function annotation in den Block der Auflösung der modalen Konfiguration verwendet.

var modalInstance = $uibModal.open({ 
    templateUrl: 'preferences.html', 
    controller: 'preferencesCtrl as ctrl', // this external controller was using explicit function annotation... 
    resolve: { 
    parent: [function() { 
     return ctrl; 
    }], 
    sectorList: ['preferencesService', function(preferencesService) { // but this was not! 
     return preferencesService.getSectors(); 
    }] 
    } 
}); 

Hoffnung das spart jemand anderes ein graues Haar oder zwei ...