Closed ZoolWay closed 7 years ago
Closing this as a dupe. We're planning to enable typed bindables which would convert properties automatically without the need to use the binding as you have above. Thanks for the feedback!
@EisenbergEffect Thanks for your response Rob! Is there a place where I can get to know about upcoming planned features?
Only searching issues tagged as enhancement.
On Mar 27, 2017 12:10 AM, "Ricky Blankenaufulland" notifications@github.com wrote:
@EisenbergEffect https://github.com/EisenbergEffect Thanks for your response Rob! Is there a place where I can get to know about upcoming planned features?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aurelia/templating-binding/issues/112#issuecomment-289371475, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIBnczTLUPP0d3bYskymWjkCVkCknJGks5rp2DngaJpZM4MoFoa .
I'm submitting a feature request
Library Version: aurelia-framework 1.1.0 aurelia-templating-binding 1.3.0
Operating System: Windows 10
Node Version: 6.5.0
NPM Version: 3.10.5
JSPM OR Webpack AND Version JSPM 0.16.52
Browser: Chrome 57
Language: all / TypeScript 2.2.1
Current behavior: When having a custom component with a bindable value which should be a boolean to have a switch on your component, it is hard to activate it without using a binding / variable because the attribute value "true" is a string which evaluates to
false
.You have to use a binding (if the value is static,
one-time
is appropiate) to have a boolean value be recognized.See: https://gist.run/?id=8204ba8ba4b1e37baa84eed0dcc5457f
Expected/desired behavior: If my component member variable is a boolean it would be nice to have a proper conversion from the string attribute value "true" to that type. Of course knowing if the member is a boolean is only possible with TypeScript (which I use). For ESnext maybe we could configure some kind of global conversion of the string
"true"
to the boolean valuetrue
for bindables? For"false"
the difference does not matter as long as I do not use three equal operations===
.What is the motivation / use case for changing the behavior? Setting component bindable value to static value without using a binding feels much more natural for the developer. If you want to enable it,
feels much more intuitive than the current necessary approach
Also to not use a binding might improve performance (although
one-time
should not be a great hit on performance).Notes Similar conversion might be interesting for numbers, too.