Is there a way to automatically assign the same value to two input fields in Angular? In this case, the variable first
needs to be set to second
without requiring user input.
Model
export class Exp{
id: number;
first: any;
second: any;
}
HTML
<label>Enter value for first:</label>
<input type="text" [(ngModel)]="exp.first" class="form-control">
<input type="hidden" [(ngModel)]="exp.second" class="form-control">
<button (click)="add()">Add</button>
TypeScript
add(){
this.myService.add(this.exp).subscribe(
data => {this.exp=data;},
error => {console.log('error');}
);
}