如何关闭angularjs中的对话框

时间:2016-12-12 08:20:24

标签: javascript angularjs twitter-bootstrap

我正在显示注册表格的弹出窗口,当我点击条款时我会显示另一个弹出窗口,但问题是当我关闭术语弹出窗口时,前一个注册模式也在关闭。

HTML                                                                                                               

<div class="modal-header">
    <h3 class="login-header" ng-if="showLoginForm" >Login to your account. Don't have an account? <a href="#" ng-click="showForm('register')">Register</a> for free!</h3>
    <p class="register-header" ng-if="showRegForm" >Please register for <b>free!</b> We collect certain information about you to provide personalized recommendations. (Don't worry) We will never share your personally identifiable information. <a href="#" ng-click="navigateFaq()">[Read More]</a></p>
    <h3 class="register-header" ng-if="showForgotForm" >Reset password</h3>
</div>
<div class="modal-body paddingmodal2">
     <div class="col_full">
         <input type="checkbox"  ng-class="{'error': submitted && registerLoginForm.terms.$error.required}"  name="terms" value="check"   id="agree"  ng-model="register.terms" required/> I agree to the XpertDox <a href="#" ng-click="termsandPolicy('terms')">Terms of Use</a> & <a href="#" ng-click="termsandPolicy('privacy')">Privacy Policy.</a>
     </div>
</div>

<div class="modal fade termmodal" id="terms-model" tabindex="-1" role="dialog" aria-labelledby="myModaqlLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-body">
            <div class="modal-content">
                <div ng-include="'app/templates/terms-model.html'"></div>
            </div>
        </div>
    </div>
</div>

<div class="modal fade termmodal" id="policy-model" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-body">
            <div class="modal-content">
                <div ng-include="'app/templates/policy-model.html'"></div>
            </div>
        </div>
    </div>
</div>

JS

$scope.termsandPolicy = function(type){
    if(type == 'terms'){
         $scope.showTerms = true;
         $('#terms-model').modal('show');
    }else{
         $('#policy-model').modal('show');   
    }

我只是将上面的代码放在我的主模式中,任何人都可以帮助我。

1 个答案:

答案 0 :(得分:0)

这种情况正在发生,因为两个模态都在同一主模型中以及控制器和同一模型中。如果您将其中一个模型更改为$ rootScope,那么它将被解析。