-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
is there a more idiomatic way to dynamically change components #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
+1 |
It's fine to create childVMs in directives as long as you manage them well - that's how some internal directives are implemented too. There's an internal method on Compiler instances called To address your |
a bit cumbersome |
Because dynamically swapping components is not that easy :) |
Thanks, @yyx990803. That all makes a lot of sense and will let me fix some of the rough edges of the dynamic component. Any ideas why the second example I gave does not work? Something to do with the compilation order? It seems to get stuck in a loop. |
I've got a pretty rough implementation here: http://jsfiddle.net/yyx990803/LgzwF/3/ It accounts for:
|
Very cool. Is this something that belongs in userland? How would you compare the complexity of this directive to others directives you've built for real projects which did not make it into "core" Vue? |
I'd say it should be pretty rare to do this type of logic control directives in userland... |
Introduced new directive: |
wow this is so cool! |
Here's a stripped down version of what I want to do. My question is if there is a better / more idiomatic way to do this (with or without the new conditional components capability). A couple things I think are wrong / less than ideal with the current example:
$appendTo
in the directive without regard to existing markupdata
element of the model that is being sent to the dynamic components is hard coded and cannot be passed inThe components that are being swapped in and out are simplistic to keep the example simple (I know there are easier ways to switch a class :) )
I think something like this would be pretty cool, but it does not work.
The text was updated successfully, but these errors were encountered: