如何根据条件停止引导数据目标的打开

时间:2017-11-22 14:58:58

标签: angularjs html5 bootstrap-4

<button type="button" id="submitButton1"  name="submitButton1"
        class="btn btn-primary waves-effect waves-light"
        ng-click =  "validateAndSaveData('upload')"
        value="Upload Documents" data-target="#myModal1"
        data-toggle="modal">Upload
</button>

我正在添加一个函数来验证表单的字段,如果满足所有条件,我希望触发datatarget。

$scope.validateAndSaveData= function(initiatorName,emailId,actionType){

    if( angular.isUndefined($scope.requestType)){
                    alert("Kindly Select Request Type");
                    $('#requestType').focus();
                    return false;
    }
}

如果此函数返回false,则表示不应触发模型。

1 个答案:

答案 0 :(得分:0)

只需通过javascript触发模态

<button type="button" id="submitButton1"  name="submitButton1" class="btn btn-primary waves-effect waves-light" ng-click =  "validateAndSaveData('upload')"  value="Upload Documents" data-target="#myModal1">Upload</button>

$scope.validateAndSaveData= function(initiatorName,emailId,actionType){


                if( angular.isUndefined($scope.requestType)){
                                alert("Kindly Select Request Type");
                                $('#requestType').focus();
                } else {
                     var id = $('#requestType').data('target');
                     $(id).modal('show'); 
                }
}