build - angular-ui-bootstrap 缩小时会导致未知的提供程序错误

标签 build gruntjs yeoman angular-ui-bootstrap

在我的 yeoman 应用程序上添加 angular-ui-bootstrap 并运行 grunt serve 后,它运行完美,并且我想要显示的模式正确显示,但是一旦我进行 grunt 构建,我的控制台中就会出现未知的提供程序错误。

<!-- 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'
])

在 Controller 中,
.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');
  };
};

};

最佳答案

对于刚遇到此问题的任何人,也许这会有所帮助。
我们使用customModalDefaults和customModalOptions,所以我们不得不把整个return $modal.open(tempModalDefaults).result;在 show 函数中如下:

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;
};

关于build - angular-ui-bootstrap 缩小时会导致未知的提供程序错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23553974/

相关文章:

c# - 使用 TFS 2012 构建服务器构建 VS2017 项目

build - Bazel:从非标准位置使用 swig

javascript - 咕噜声 : Watch and synchronize files

angularjs - 使用 grun 构建时 dist 中没有 View

javascript - Angular-Slick 与 Grunt

scala - Build Sync 在 IntelliJ 中意味着什么

java - Maven 构建编译错误 : Failed to execute goal org. apache.maven.plugins :maven-compiler-plugin:3. 1:在项目 Maven 上编译(默认编译)

javascript - Grunt CSS 缩小和谷歌字体

yeoman - jhipster 应用程序文件在错误的目录中生成

sass - 如何处理 Bower 组件图像、字体或其他 Assets (使用自耕农)?