What is the difference of using @bind
and @bind-value
?
I made this simple example, and testing it in the browser, I didn\'t see any difference.
Quoting Component Binding docs:
Data binding to both components and DOM elements is accomplished with the
@bind
attribute. (...) Using@bind
with aCurrentValue
property () is essentially equivalent to the following:
CurrentValue = __e.Value)" />
In addition to handling onchange events with
@bind
syntax, a property or field can be bound using other events by specifying an@bind-value
attribute with an event parameter (@bind-value:event
). (onchange
,oninput
)
Summarizing
If you want to reset binded value on each input change (instead to set all changes at once on lost input focus) you should to use @bind-value
and oninput
on @bind-value:event
:
If you try to use @bind-value:event
without @bind-value
(using just @bind
) a pre-compiling error is raised:
error RZ10004: Could not find the non-parameterized bind attribute that corresponds to the attribute 'bind-value:event'
But the XXX.razor.g.cs
generated file is the same for @bind
and @bind-value
.