2017-06-19 29 views
0

我想在AngularJs中使用下拉菜單,我可以打開彈出窗口在單頁面應用程序中添加額外的項目。在Angular JS中彈出選項的下拉菜單

AngularJs有這樣的機會嗎?

我該如何做到這一點?

(例如)

enter image description here

回答

0

你需要像http://plnkr.co/edit/LYOEntdgLbONNAzH0Ove?p=preview

定義每個值一個模式模板 - modal1,modal2 ..

<script type="text/ng-template" id="modal1.html"> 
    <div class="modal-header"> 
    <h3 class="modal-title">modal1 - {{ action }}</h3> 
    </div> 
    <div class="modal-body"> 
    modal1 
    </div> 
    <div class="modal-footer"> 
    <button class="btn btn-primary" type="button" ng-click="ok()">OK</button> 
    <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button> 
    </div> 
</script> 

這個功能

$scope.showModal = function(action) { 
    if (!$scope.modes.mode) return 
    $scope.action = action 
    $scope.modal = $uibModal.open({ 
    templateUrl: $scope.modes.mode+'.html', 
    scope: $scope 
    }); 
} 

你打電話的ShowModal從按鈕ng-click處理器(動作只是爲了演示模板/按鈕關係)

$scope.delete = function() { 
    $scope.showModal('delete') 
} 
... 
+0

類似的東西,但是當你點擊正是在下拉菜單中的項目時,它會觸發彈出不需要另一個按鈕。 @ D.Elvis – gobo

+0

嘗試在