To this question asking how to protect [(ngModel)]="currentService.user.username"
when the variable is not yet defined, the following answer was given:
<input [(ngModel)]="currentService.user && currentService.user.username">
At first, I thought that this could not work because the bound expression would not be a valid left-hand side in an assignment:
(this.currentService.user && this.currentService.user.username) = "Bob"; // Not valid
However, Pardeep Jain provided a demo which showed that it does work: the variable currentService.user.username
is bound to the input element once it is defined. This stackblitz is a forked version of his demo.
My question: is binding a conditional expression this way with [(ngModel)]
supposed to work or does it work only "by accident" and may stop working in future versions of Angular?