我使用範圍欄從RzSlider V2.0.1在我的應用程序,其中RZ-滑蓋機型值可以是未定義或一個int值。AngularJS RzSlider:如果rz-slider-model未定義或爲null,我該如何默認?
下面是我的HTML模板
<tr ng-repeat="feature in categories">
<td>
{{feature.featureName}}
<rzslider rz-slider-model="feature.slider.selectedMin" rz-slider-high="feature.slider.selectedMax" rz-slider-options="{floor:feature.slider.min, ceil:feature.slider.max, onChange: editor.slideChange(categoryId, feature.value, feature.slider.selectedMin, feature.slider.selectedMax)}"></rzslider>
</td>
</tr>
與模型價值可以像這些
[{
"slider": {
"min": 0,
"max": 10,
"selectedMin": 2,
"selectedMax": 4
},
"value": "1",
"featureName": "Fuel"
},
{
"slider": {
"max": 10,
"selectedMin": null,
"selectedMax": 5
},
"value": "2",
"featureName": "Large"
}]
什麼現在,我怎麼可以默認rz-slider-model
價值0
如果從API返回我的JSON對象null
。
我已嘗試設置類似rz-slider-model='feature.slider.selectedMin || 0'
但得到的異常而改變像Error: [$compile:nonassign] Expression 'feature.slider.selectedMin || 0' used with directive 'rzslider' is non-assignable!
滑塊值可以找到示例代碼here
請幫幫忙!