作者:木子小平方_530 | 来源:互联网 | 2023-09-15 17:34
WhenusingRadiobuttonforTamplatedrivenform,wewanttochangetothevaluechangeandpreformsomeacti
When using Radio button for Tamplate driven form, we want to change to the value change and preform some action.
import { Component, Input } from '@angular/core';
import { Passenger } from '../../models/passenger.interface';
@Component({
selector: 'passenger-form',
styleUrls: ['passenger-form.component.scss'],
template: `
"ngForm" novalidate>
{{ detail | json }}
Passenger name:
<input
type="text"
name="fullname"
[ngModel]="detail?.fullname">
Passenger ID:
<input
type="number"
name="id"
[ngModel]="detail?.id">
"form.value.checkedIn">
Check in date:
<input
type="number"
name="checkInDate"
[ngModel]="detail?.checkInDate">
{{ form.value | json }}
`
})
export class PassengerFormComponent {
@Input()
detail: Passenger;
toggleCheckIn(checkedIn: boolean) {
if (checkedIn) {
this.detail.checkInDate = Date.now();
}
}
}