Angular Bootstrap ng-show模式

时间:2015-11-30 20:35:27

标签: html angularjs twitter-bootstrap-3

因此,如果属性触发器为false,我想显示一个bootstrap模式,如下面的代码所示。基本上,如果在上面的控件中选择的一个好处有一个hasFunds的属性为false,那么一旦选择了这个好处就显示模态(将在底部显示该代码),但如果为真,则模态没有任何反应。

模态代码:

<!-- hasFunds Modal -->
<div class="modal fade" id="hasFundsModal" tabindex="-1" role="dialog" aria-labelledby="hasFundsModalLabel" aria-hidden="true" ng-show="benefit.hasFunds == false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                &times;
                <p>You have already claimed the full amount of your benefit, and so there may be no remaining funds to reimburse this claim. Are you sure you want to continue?</p>
            </div>
            <div class="modal-footer">
                <input type="button" class="naviaBtn naviaBlue" data-dismiss="modal" value="yes">
                <input type="button" class="naviaBtn naviaBlue" data-dismiss="modal" value="no">                                        
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

上面的控件有一个下拉选择器,其中包含触发true或false的属性:

<div class="form-group col-md-6 naviaInp">
    <label for="beneSelect">Select your benefit</label>
    <select class="form-control" name="beneSelect" id="beneSelect" ng-model="benefit" ng-options="item.descr for item in claim" ng-required="true">
         <option value="">Please select a benefit....</option>
     </select>
    <input type="hidden" ng-model="claimInfo.benefitId" ng-change="{{ claimInfo.benefitId = benefit.id }}"/>
</div>
<div ng-show="claimForm.beneSelect.$dirty && claimForm.beneSelect.$error.required" class="errorContainer">
    <p class="claimError"><i class="fa fa-exclamation-circle"></i><span>this is a required field</span></p>
</div>  

目前,没有模态显示是真还是假。是否可以通过ng-show触发模态?

非常感谢。

1 个答案:

答案 0 :(得分:0)

如果您使用的是UI Bootstrap,请参阅Modal指令的文档:https://angular-ui.github.io/bootstrap/#/modal

您需要使用控制器中的选项参数调用$uibModal.open(),以便显示模式。