I would like the child component value to be bound to the parent component. How to accomplish this when @Input()
and [(ngModel)]
are not enough ?
Here you have to set @Output
also and change the component like
export class CounterComponent {
@Output('initoChange') emitter: EventEmitter<string> = new EventEmitter<string>();
@Input('inito') set setInitoValue(value) {
this.count = value;
}
count: number = 0;
increment() {
this.count++;
this.emitter.emit(this.count);
}
decrement() {
this.count--;
this.emitter.emit(this.count);
}
}
Here is the link to plunker , please have a look.