Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap-angular-ui modal on load

I am using bootstrap-angular-ui-modal for a site I am working on. The code I am using to open the modal

$modal.open(
    {
        templateUrl: '/home/template',
        controller: myCtrl,
        resolve: {
            data: function () {
                return data;
            }
        }
    });

Everything is working fine. But I need to find a way to execute some code after modal is loaded. I tried different things but can't make them work. Some of things I tried

In template I did

<script>
    document.onload = function () {
        console.log('opened');
    };
</script>

I also found there is a promise for the angular modal object named openned. I tried to

modalInstance.opened.then(function(){console.log('hello')});

not working either. I can use some help here.

like image 409
Hossain Muctadir Avatar asked Oct 29 '13 11:10

Hossain Muctadir


1 Answers

This is definitely not a good solution, but at least worked for me. I just added a timeout before executing the desired function,

modalInstance.opened.then(
    $timeout(function() {
            console.log('hello');
        }, delay));
like image 169
Hossain Muctadir Avatar answered Sep 19 '22 13:09

Hossain Muctadir