我有一个循环创建不同的ng2-noUiSliders,如下所示:
<div *ngFor="let property of completeFilters">
<h5>{{property.propertyName | translate}}</h5>
<div *ngIf="setSliderValues(property); else renderCheckbox">
<nouislider #sliderRef [config]="conf" [tooltips]="[true, true]" (end)="onSliderChange($event, property.propertyName)"></nouislider>
</div>
创建的滑块是范围滑块,其中一个是价格滑块。更改货币时,我想用其他值更新最大滑块最大值。到目前为止,我能够像这样拿起滑块:
@ViewChildren('sliderRef') public salesSliders: QueryList<NouisliderComponent>;
this.salesSliders.toArray()[0]; //the slider I want to update
this.salesSliders.toArray()[1];
...
但我无法使用我见过的updateOptions示例。有没有人这样做的时候有一个像我这样的循环中创建的滑块?
要使用最新值更新UI,您需要执行以下步骤
// Import this in componnet where your are updating the values
import { ChangeDetectorRef } from '@angular/core';
constructor(private cd: ChangeDetectorRef) {}
//call below method after you changes
this.cd.detectChanges();