Angularjs 从单个指令打开/关闭多个模态

Angularjs 从单个指令打开/关闭多个模态,angularjs,twitter-bootstrap-2,Angularjs,Twitter Bootstrap 2,我现在正在使用多个模态来引导用户通过一个表单,并且我已经创建了一个指令来打开/关闭每个模态的模态。我做过这样的事情: .directive('firstModal', function() { // Series of directives used to open/close target modals return { restrict: 'A', link: function(scope, e

我现在正在使用多个模态来引导用户通过一个表单,并且我已经创建了一个指令来打开/关闭每个模态的模态。我做过这样的事情:

.directive('firstModal', function() {                  // Series of directives used to open/close target modals
        return {
            restrict: 'A',
            link: function(scope, element, attr) {
                scope.dismissFirst = function() {
                    element.modal('hide');
                };
                scope.showFirst = function() {
                    element.modal('show');
                };
            }
        };
    }

我已经查看了ui.bootstrap和angular-strap,但是它们都用于bootstrap 3.x-这个站点仍然运行在bootstrap 2.3上,所以我认为在升级站点之前,我不会使用这两个选项中的任何一个。我的问题是,有没有一种方法可以从一个指令处理所有模态的打开/关闭

从dah wahlin签出此链接,其中包含使用

下面是一个关于如何使用$modal的示例

app.controller('ModalCtrl', function($scope,  $modal) {

      $scope.name = 'theNameHasBeenPassed';

      $scope.showModal = function() {

        $scope.opts = {
        backdrop: true,
        backdropClick: true,
        dialogFade: false,
        keyboard: true,
        templateUrl : 'modalContent.html',
        controller : ModalInstanceCtrl,
        resolve: {} // empty storage
          };


        $scope.opts.resolve.item = function() {
            return angular.copy(
                                {name: $scope.name}
                          ); // pass name to resolve storage
        }

          var modalInstance = $modal.open($scope.opts);

          modalInstance.result.then(function(){
            //on ok button press 
          },function(){
            //on cancel button press
            console.log("Modal Closed");
          });
      };                   
})

var ModalInstanceCtrl = function($scope, $modalInstance, $modal, item) {

     $scope.item = item;

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

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


我从

中复制了这个答案。您可以使用ui引导v0.8.0,这是最后一个支持引导2.3的版本。您知道v0.8.0的任何现有文档吗?我在谷歌搜索时找不到任何文档,似乎开发人员在发布v0.11.0时没有保存文档的副本。文档链接,因为他们已将其删除