This diagnostic detects a backwards "banana-in-box" syntax for two-way bindings.
<div ([var])="otherVar"></div>
As it stands, ([var])
is actually an event binding with the name [var]
. The author likely intended this as a two-way binding to a variable named var
but, as written, this binding has no effect.
Fix the typo. As the name suggests, the banana (
should go inside the box []
. In this case:
<div [(var)]="otherVar"></div>
strictTemplates
must be enabled for any extended diagnostic to emit. invalidBananaInBox
has no additional requirements beyond strictTemplates
.
This diagnostic can be disabled by editing the project's tsconfig.json
file:
{ "angularCompilerOptions": { "extendedDiagnostics": { "checks": { "invalidBananaInBox": "suppress" } } } }
See extended diagnostic configuration for more info.
© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/extended-diagnostics/NG8101