Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

open modal/aside at a certain state with ui-router #1735

Closed
nightire opened this issue Jun 16, 2015 · 5 comments
Closed

open modal/aside at a certain state with ui-router #1735

nightire opened this issue Jun 16, 2015 · 5 comments

Comments

@nightire
Copy link

Here's example that ui-router provides us to demonstrate how to open a modal (using ui-bootstrap) at a certain state other than swapping out ui-view(s):

https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-open-a-dialogmodal-at-a-certain-state

I want to archive the same goal when using angular-strap, but can't find a working way, anyone knows any working solution?

@vmlf01
Copy link
Collaborator

vmlf01 commented Jun 16, 2015

Have a look at this plunker, it makes use of a custom modal service to make it easier to define what to do when a button is pressed:
http://plnkr.co/edit/ylhw0hT3vUz67WNBSYHW?p=preview

From looking at ui-router sample, it looks like it could work the same way as for ui-bootstrap.

@nightire
Copy link
Author

@vmlf01 thanks for your example, I've tried similar solution but still no luck, I've using this kind of custom modal service in state's onEnter callback, but when state has changed nothing happens at all.

I don't know why but seems your example only works well in an existing controller, since ui-bootstrap's modal provide its own controller, we don't need to create a controller for state. I can't say this is the key but I guess so...

could you take a little time to try your solution with ui-router please? thank you in advance.

@nightire
Copy link
Author

@vmlf01 Thank you, finally I've figured out how to do this, however it is almost useless when using ngStrap's modal/aside.

Why I need a new state with modal/aside? because I need a new state to manage more complex business logic with modal/aside, I need to split these kinds of logic when a modal/aside evolves, which means not only a modal/aside directive w/o service is needed, but also a controller/resolve mechanism is necessary to handle this sort of situation.

This is what ui-bootstap's modal does but ngStrap modal/aside don't. I can open modals/asides when corresponding states changed, but I can't provide alongside logic for each of them, unless to write multiple wrapper services for every instance, that's insane.

I compared the source code between ui-bootstrap's and ngStrap's implement, found out it is very hard to customize a service to archive the same purpose in this case, but I really think this is useful for everyone.

Anyway, thanks again @vmlf01 I've learned a lot from your example, for now I can't find any better way to improve this.

@mgcrea mgcrea closed this as completed in 8e54db8 Jul 12, 2015
mgcrea added a commit that referenced this issue Jul 12, 2015
…or `controller`, `controllerAs`, `template`, `templateUrl` options (fixes #732, fixes #728, fixes #1394, fixes #1735)
mgcrea added a commit that referenced this issue Jul 12, 2015
…or `controller`, `controllerAs`, `template`, `templateUrl` options (fixes #732, fixes #728, fixes #1394, fixes #1735)
@mgcrea
Copy link
Owner

mgcrea commented Jul 12, 2015

Finally took the time to backport the bsCompiler from angular-material's project. You can now use controller, controllerAs, templateUrl and template options in your modal and derivatives. Hope it solves most of the issues you encountered with AngularStrap's modals.

@lock
Copy link

lock bot commented Jan 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the outdated label Jan 26, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants