2017-06-19 59 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

尝试在