Similar to how you can two-way bind [(ngModel)]
you can two-way bind custom property on a component, for example [(value)]
. To do it use appropriate Input/Output naming:
@Component({
selector: 'super-input',
template: `...`,
})
export class AppComponent {
@Input() value: string;
@Output() valueChange = new EventEmitter<string>();
}
Then you can use it as:
<super-input [(value)]="value"></super-input>