Which @angular/* package(s) are the source of the bug?
forms
Description
Hey!
Currently, the following code does not produce any compile-time error, but I believe it should:
@Component({
selector: 'TextInput',
template: `
<input
type="text"
[value]="value()"
(input)="value.set($event.target.value)" />
`,
})
export class TextInput implements FormValueControl<string> {
readonly value = model('');
}
@Component({
selector: 'app-root',
imports: [FormField, TextInput],
template: `
<TextInput [formField]="form.name" [(value)]="test" />
<p>{{ form.name().value() }}</p>
<button (click)="random()">Change it</button>
`,
})
export class App {
protected readonly test = signal('');
protected readonly form = form(signal({ name: '' }), (schema) => {
minLength(schema.name, 3, {
message: 'Name must be at least 3 characters',
});
});
protected random() {
this.test.set(`${Date.now()}`);
}
}
Note that <TextInput [formField]="form.name" [value]="test()" /> correctly reports NG8022: Binding to '[value]' is not allowed on nodes using the '[formField]' directive.
I would expect the two-way binding [(value)]="test" to be caught as well.
Cheers!
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-qeuguesw
Which @angular/* package(s) are the source of the bug?
forms
Description
Hey!
Currently, the following code does not produce any compile-time error, but I believe it should:
Note that
<TextInput [formField]="form.name" [value]="test()" />correctly reportsNG8022: Binding to '[value]' is not allowed on nodes using the '[formField]' directive.I would expect the two-way binding [(value)]="test" to be caught as well.
Cheers!
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-qeuguesw