如何必须使用 angularjs 模式

how to have to modal with angularjs

我试过这个插件

http://plnkr.co/edit/s902hdUIjKJo0h6u6k0l?p=preview

 angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl', function  ($scope, $modalInstance, items) {

但是报错 错误:[$injector:unpr] 未知提供者:itemsProvider <- items

我想要两个具有 2 个不同模式的按钮

有很多语法错误: 更新了 plunker http://plnkr.co/edit/vgM5PLyVgluOeikGvVSA?p=preview

在 JS 中所做的更改:-

angular.module('ui.bootstrap.demo', ['ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('ModalDemoCtrl', function ($scope, $modal, $log) {

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

  $scope.open = function (size) {

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

    modalInstance.result.then(function (selectedItem) {
      $scope.selected = selectedItem;
    }, function () {
      $log.info('Modal dismissed at: ' + new Date());
    });
  };
});



angular.module('ui.bootstrap.demo').controller('ModalDemoCtrl2', function ($scope, $modal, $log) {

  $scope.items2 = ['item12', 'item22', 'item32'];

  $scope.open = function (size) {

    var modalInstance2 = $modal.open({
      templateUrl: 'myModalContent2.html',
      controller: 'ModalInstanceCtrl2',
      size: size,
      resolve: {
        items2: function () {
          return $scope.items2;
        }
      }
    });

    modalInstance2.result.then(function (selectedItem) {
      $scope.selected = selectedItem;
    }, function () {
      $log.info('Modal dismissed at: ' + new Date());
    });
  };
});

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

angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl', function ($scope, $modalInstance, items) {

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

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

  $scope.cancel = function () {
    $modalInstance.dismiss('cancel');
  };
});
angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl2', function ($scope, $modalInstance, items2) {

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

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

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

您可以尝试我的 Angular 对话服务,它建立在 ui.bootstrap 的模式之上,但为错误、通知、进度、确认和自定义对话框提供预制模式。它允许您使用 'dialogsProvider' 在应用程序的配置函数中设置配置,这样您就不必每次都设置键盘和背景设置。还支持使用 angular-translate 和 fontAwesome。

您可以在这里找到它:https://github.com/m-e-conroy/angular-dialog-service 或 bower.io.