ClickerMonkey / SemanticUI-Angular

Angular Directives for Semantic UI
http://clickermonkey.github.io/SemanticUI-Angular/examples/
MIT License
56 stars 28 forks source link

How to control the modal from a controller? #10

Closed dantium closed 7 years ago

dantium commented 8 years ago

What would be the best way to control a modal from a controller? I would like to open it and have a loading spinner while getting remote content. Sorry if I missed something in the docs, thanks in advance!

ClickerMonkey commented 8 years ago

Modals are done a little differently than other frameworks - there's a visible attribute on the directive which watches a variable for changes. If you want to open it based on a DOM event you can use sm-modal-show or sm-modal-hide.

http://clickermonkey.github.io/SemanticUI-Angular/src/modal/directives.html

Check out the attributes and the sm-modal-show example on that page.

dantium commented 8 years ago

Thanks that's great!

LabN36 commented 6 years ago

hey @ClickerMonkey can you guide how can i display the modal from controller itself instead of using sm-modal-show in button ?

ClickerMonkey commented 6 years ago

You can use the visible attribute of sm-modal and just set it to true in your controller. Checkout the examples!

On Nov 25, 2017 9:31 AM, "Rishabh Agrawal" notifications@github.com wrote:

hey @ClickerMonkey https://github.com/clickermonkey can you guide how can i display the modal from controller itself instead of using sm-modal-show in button ?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ClickerMonkey/SemanticUI-Angular/issues/10#issuecomment-346943913, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZtcTtUGNtJs0W0snQrXNjImAdrI22Yks5s6CSxgaJpZM4JDkrx .

LabN36 commented 6 years ago

I've tried that earlier but it's not working

here is the code

html

<sm-modal   visible="test" >
  <h1>Hello Modal</h1>
</sm-modal>

controller

function verifyEmailController($scope, $http, SemanticUI) { $scope.test = true; }

additionally on console i'm getting element.modal is not a function

any help would be really appreciated

ClickerMonkey commented 6 years ago

If you're seeing that error it sounds like you're missing jQuery and or Semantic JS. OR you need to include jQuery before angular

On Nov 25, 2017 9:54 AM, "Rishabh Agrawal" notifications@github.com wrote:

I've tried that earlier but it's not working

here is the code

html Hello Modal controller

function verifyEmailController($scope, $http, SemanticUI) { $scope.test = true; }

additionally on console i'm getting element.modal is not a function

any help would be really appreciated

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ClickerMonkey/SemanticUI-Angular/issues/10#issuecomment-346945202, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZtcU7SEODTahQNRJSF9zKNtM0VvRcPks5s6CoegaJpZM4JDkrx .