2014-01-05 80 views
0

我採用了棱角分明的UI情態動詞(http://angular-ui.github.io/bootstrap/#modal顯示多模態在一個循環中

我必須表現出同樣的模式,多次在一個循環。

比如我有一個團隊,我需要表現出每個人在繼承(基本上這是一個嚮導)編輯團隊成員模態

我的問題是,它打開所有的情態動詞,堆放在彼此頂部,我想讓他們一次打開一個。

for (var i = 0; i < team.SizeLimit; i++) { 
    var participant = { }; // assume this hold the correct participant 

    var openModal = $modal.open({ 
     templateUrl: '/Modals/Participant/Edit.html', 
     backdrop: true, 
     windowClass: 'modal', 
     controller: 'ModalParticipantController', 
     resolve: { 
      title: function() { return 'Edit Participant'; }, 
      participant: function() { return participant; } 
     } 
    }); 

    openModal.result.then(function (data) { 
     alert('success!'); 
    }); 
} 

我該如何獲得它來連續打開這些模式,因爲模式一次關閉一次?

回答

1

我不是一個angularJs的用戶,但我有一段時間後,同樣的問題。

不是在循環中創建模態,而是使用模態本身創建循環,在關閉當前模態時檢查下一個參與者。 (我猜openModal.result.then()是回調)

var fnOpenModal = function(i) { 
     if (i >= team.sizeLimit) 
      return; 

     var participant = team[i], 
      openModal = $modal.open({ 
       .... 
      }); 

     openModal.result.then(function (data) { 
      alert('success!'); 
      fnOpenModal(i + 1); 
     }); 
    } 
fnOpenModal(0); 

它definetly不是最好的解決辦法,但它是一個快速的作品:-)

+0

這看起來很有希望,我正在思考這些問題,但假期和假期似乎讓我的大腦萎縮了。 – CaffGeek

+0

好吧,我只是看着你的個人資料,並去'爲什麼會有這樣的經歷的人問這個?'。你剛給了一個合理的解釋,哈哈。 – DoXicK