1

I have been trying to make make the modal appear, but have failed to do so after multiple attempts.

Here is the code for the modal:

<!-- Login modal -->   
<div class="modal fade" id="login_2" tabindex="-1" role="dialog" aria-labelledby="myLogin" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content modal-popup">
                <a href="#" class="close-link"><i class="icon_close_alt2"></i></a>
                <form action="#" class="popup-form" id="myLogin">
                    <div class="login_icon"><i class="icon_lock_alt"></i></div>
                    <input type="text" class="form-control form-white" placeholder="Username">
                    <input type="text" class="form-control form-white" placeholder="Password">
                    <div class="text-left">
                        <a href="#">Forgot Password?</a>
                    </div>
                    <button type="submit" class="btn btn-submit">Submit</button>
                </form>
            </div>
        </div>
    </div><!-- End modal -->

What I want to do is to load this modal automatically if a certain variable is set in $stateParams in the controller. Otherwise, it should remain hidden. I have tried angular.element('login_2').modal() without success

3 Answers 3

1

Use ng-show link to documentation.

You can make something like:

<div class="modal fade" ng-show="showMyModal" ...

And a checkbox for controlling it (but you can do anything)

<input type="checkbox" ng-model="showMyModal">

Remember that you can animate ngShow with ngAnimate.

Sign up to request clarification or add additional context in comments.

Comments

1

If you're open to using an existing library (that isn't ui bootstrap), I recommend ngDialog. You can use custom HTML templates and styles and it's just for creating modals.

Comments

0

Just toggle it like this.

$('#login_2').modal('show');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.