下面管是不工作的我的角分量模板的部分:角2旋轉器,滑塊:定製不工作
<p-spinner id="yzDistance"
[min]="aRenderState.clipping.planes[0].min"
[max]="aRenderState.clipping.planes[0].max"
[step]="inputStep"
[(ngModel)]="yzDistance" (onChange)="moveClip(0)">
</p-spinner>
<input type="range" class="slider" type="range" name="yzDistance"
[min]="aRenderState.clipping.planes[0].min"
[max]="aRenderState.clipping.planes[0].max"
[step]="inputStep"
[ngModel]="yzDistance | decimalsPipe"
(ngModelChange)="yzDistance=$event"
(input)="moveClip(0)">
旋轉器工作正常放映值正確格式化例如2.009 4.765 -1.649等(小數點後3位)。當我移動的滑塊也有0.001步時,微調器得到更新,但顯示有千位分隔符的小數點,例如3.987,432 -1.34,092等我試圖糾正以下自定義管叫decimalsPipe問題:
@Pipe({name: 'decimalsPipe'})
export class DecimalsPipe implements PipeTransform {
transform(value) {
value.toLocaleString('en-US', {
minimumFractionDigits: 0,
maximumFractionDigits: 3
});
}
}
@Component({
selector: 'myComponent',
templateUrl: './myComponent.html',
styleUrls: ['./myComponent.css']
})
export class myComponent { ...
它仍然呈現怪異的十進制格式,它不會引發錯誤。你能幫我解決這個問題嗎?
謝謝,迪諾
仍然無法正常工作,但您的答案非常有用。我在spinner下添加了一段顯示{{yzDistance | decimalsPipe}},我可以看到該值的格式正確。所以問題是primeng是搞亂格式與十進制增量。 –
Dino