调用从角度控制器的自举模式 [英] Calling a bootstrap modal from an Angular Controller

查看:105
本文介绍了调用从角度控制器的自举模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要替换的警报中产生成功发送的邮件的角度控制器的自举模式。 (实际的邮件发送香饽饽与PHPMailer的完成)

I want to replace an alert for a bootstrap modal in the Angular controller that produces the successful sent mail. (The actual mail sending meat and potatoes is done with PHPMailer)

所以,这是我的控制器:

So, this is my controller:

// create angular controller
app.controller('form', function($scope) {

    // function to submit the form after all validation has occurred            
    $scope.submitForm = function(isValid) {

        // check to make sure the form is completely valid
        if (isValid) {      
           alert('our form is amazing');
        }

    };
});

我想从该呼叫警报('我们的表单...')更改为< D​​IV CLASS =模态变脸类=.....< / DIV>

现在这里是我很困惑的另一部分。我想象应该是一个办法商店的东西的模式,可以从控制器调用,而不必把整个HTML模式在那里,是吗?如果是这样,我该怎么做呢?

Now here is the other part I am confused on. I imagine the should be a way to "store" the modal in something that can be called from the controller without having to put the entire modal html in there, am I right? If so, how do I do that?

推荐答案

您可以添加模态到您的视图,然后通过ID调用它:

You could add modal to your view and then call it by id:

<div id="myModal1" class="modal fade in" class="".....</div>

..

// create angular controller
app.controller('form', function($scope) {

    // function to submit the form after all validation has occurred            
    $scope.submitForm = function(isValid) {

        // check to make sure the form is completely valid
        if (isValid) {      
           angular.element(myModal1).modal("show");
        }

    };
});

这篇关于调用从角度控制器的自举模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆