Input helper valueBinding is deprecated - what'

2019-05-18 06:24发布

问题:

I've got a few text-input helper like this

{{input type="text" valueBinding="name" focus-out="focusOutName"}}

I just upgraded Ember to 1.11.0 and now get this deprecation warning:

DEPRECATION: You're attempting to render a view by passing valueBinding to a view helper, but this syntax is deprecated. You should use value=someValue instead.

However when using value it is not bound in the controller and value simply sets the text to whatever value.

How do I correctly bind it?

回答1:

You should just have to change:

{{input type="text" valueBinding="name" focus-out="focusOutName"}}

to:

{{input type="text" value=name focus-out="focusOutName"}}

or even better (don't need the type="text", it's automatic):

{{input value=model.name focus-out="focusOutName"}}

then next to it you can display the value, and see it change when you change the input (so you can test for yourself that the bindings are set up already):

{{input value=model.name focus-out="focusOutName"}}
{{model.name}}