Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(button group): add valueChange output #2722

Merged
merged 10 commits into from
Jun 15, 2021
Prev Previous commit
Next Next commit
refactor(button group): filter out buttons without value
  • Loading branch information
yggg committed Jun 15, 2021
commit 578d81758f3b2624f58f2ba04366cce5a34e2137
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,11 @@ export class NbButtonGroupComponent implements OnChanges, AfterContentInit {
});
}

private emitCurrentValue(toggleButtons: NbButtonToggleDirective[]): void {
this.valueChange.emit(toggleButtons.filter(btn => btn.pressed).map(btn => btn.value));
protected emitCurrentValue(toggleButtons: NbButtonToggleDirective[]): void {
const pressedToggleValues = toggleButtons
.filter((b: NbButtonToggleDirective) => b.pressed && typeof b.value !== 'undefined')
.map((b: NbButtonToggleDirective) => b.value);

this.valueChange.emit(pressedToggleValues);
}
}