I am new to Angular and following the video
https://www.youtube.com/watch?v=1Es9AaNBJ5Q&list=PLOghUv2IDLKHo0CJkwLcbb1YW0As5fRZd&index=46
But, two way databinding is not working. Initially, the input text has the value [email protected] However, when I change the value and hit enter key, the value still is [email protected]
Here are all the versions Angular CLI: 16.1.4 Node: 16.15.1 Package Manager: npm 8.11.0 OS: win32 x64
import { Component } from "@angular/core";
import { CoursesService } from "./courses.service";
@Component( {
selector: 'courses',
template: `
<input type="text" [value]="email" (keyup.enter)="onKeyEnter()"/>
`
} )
export class CoursesComponent{
email:string;
constructor(service:CoursesService) {
this.email = "[email protected]";
}
onKeyEnter()
{
console.log("My new email id : " , this.email);
}
};
Try using [(ngModel)]="value"
for more ...