Angular js - call data-modal-target from controller

I am new to angular and am wondering about modal. In my html I use data-modal-target similar to this

          <li>
            <button data-modal-target='#delete-connection' ng-click="deleteConnection(cloudconnection.id)">Delete Connection</button>
          </li>

I have a div with id delete-connection defined in my html that contains the contents of a modal dialog like OK / Cancel. The above code works very well and I see a modal dialog when I click a button.

But now I want to show this modal dialog from my controller. When the button is pressed, I want to call the method in the controller, do some processing, and then conditionally show the modal dialog. What is the easiest way to show this modal dialogue? One of the ways I've seen in the other answers is to define its own controller with a template file, etc. I am wondering if I can just use my existing div for a modal dialog and somehow enable it from my controller. I tried something like -

$ ('# delete-join') modality () ;.

But I get an error indicating that $ is undefined.

Can someone tell me what to do here?

thank

+4
source share
2 answers

, jquery refernce.

angular, angular -ui

https://angular-ui.imtqy.com/bootstrap/#!#modal

0

:

  • JavaScript
  • jQuery. - , - , $.
  • JavaScript , , jQuery.

, javascript , :

$(document).ready(function () {
  //your code here
});

, jQuery. , , - , jQuery. "$", , jQuery, .

0

Source: https://habr.com/ru/post/1676110/


All Articles