Why can't we use [(ngModel)] and value in same input tag in angular 6
问题 My html tag is: <input matInput placeholder="Vehicle Number" name="vehicleNo" [(ngModel)]="vehicleNo" value="vehicle.vehicleNo" > I need to automatically fill the input field and if i enter new thing it need to access in component.ts file. 回答1: In angular if you are using ngModel to bind data then you don't need to use value attribute, it will automatically bind the data. //in ts file export className extends OnInit{ vehicle: any; ngOnInit(){ this.serviceName.functionName().subscribe( data=>{