Angular - Lifecycle Hooks
You want to reset a component's internal counter to zero whenever the input
resetFlag changes from false to true. Which ngOnChanges implementation correctly achieves this?export class CounterComponent implements OnChanges {
@Input() resetFlag = false;
@Input() otherValue: number = 0;
counter = 10;
ngOnChanges(changes: SimpleChanges) {
// Which option resets counter correctly?
}
}