在素数 ng- 输入数字微调器中循环特定范围的数字
Looping in a particular range of numbers in prime ng- input number spinner
如何循环遍历一系列数字,例如:0 到 10,在 prime ng 输入数字微调器中?
<p-inputNumber [showButtons]="true" formControlName="timeHour" [step]='1' [size]='2' value="12">
</p-inputNumber>
export class AppComponent implements OnInit, OnDestroy {
destroy$: Subject<boolean> = new Subject<boolean>();
myForm = new FormGroup({
timeHour: new FormControl(12)
});
constructor() {}
ngOnInit() {
this.spinnerChange();
}
spinnerChange(): void{
this.myForm.get('timeHour').valueChanges
.pipe(
distinctUntilChanged(),
takeUntil(this.destroy$)
)
.subscribe(x => {
const valueChangedHour = x < 1 ? 12 :
(x > 12 ? 1 : x);
this.myForm.patchValue({
timeHour : valueChangedHour
});
});
}
ngOnDestroy() {
this.destroy$.next(true);
// Now let's also unsubscribe from the subject itself:
this.destroy$.unsubscribe();
}
}
如何循环遍历一系列数字,例如:0 到 10,在 prime ng 输入数字微调器中?
<p-inputNumber [showButtons]="true" formControlName="timeHour" [step]='1' [size]='2' value="12">
</p-inputNumber>
export class AppComponent implements OnInit, OnDestroy {
destroy$: Subject<boolean> = new Subject<boolean>();
myForm = new FormGroup({
timeHour: new FormControl(12)
});
constructor() {}
ngOnInit() {
this.spinnerChange();
}
spinnerChange(): void{
this.myForm.get('timeHour').valueChanges
.pipe(
distinctUntilChanged(),
takeUntil(this.destroy$)
)
.subscribe(x => {
const valueChangedHour = x < 1 ? 12 :
(x > 12 ? 1 : x);
this.myForm.patchValue({
timeHour : valueChangedHour
});
});
}
ngOnDestroy() {
this.destroy$.next(true);
// Now let's also unsubscribe from the subject itself:
this.destroy$.unsubscribe();
}
}