If this innocent-looking code
Color: <input [(ngModel)]="color" />
gives you this error:
Type 'Event' is not assignable to type 'string'.
Add FormsModule on imports:
@Component({
selector: 'app-root',
standalone: true,
imports: [
HoverHighlightDirective,
// FormsModule, // uncomment this to remove the error: Type 'Event' is not assignable to type 'string'.
],
templateUrl: './main.html',
})
export class App {
name = 'Angular';
color: string = 'blue';
}
bootstrapApplication(App);
Test code on stackblitz:
https://stackblitz.com/edit/angular-jjw6g1cv?file=src%2Fmain.ts
No comments:
Post a Comment