我正在 angularjs 中构建一个计算器作为 wordpress php 插件。通过简码将参数作为变量传递。我有一个 jquery ui-slider,其最小值、最大值和步长值由传递的参数设置:
<div ui-slider="{range: 'min'}" min="{$this->weight_minimum}"
max="{$this->weight_maximum}" step="{$this->weight_increment}"
ng-model="weight">
</div>
我还在滑块后添加了两个单选按钮:
<div class="user-selection">
<label class="radio-container">{{ "Pounds" | translate }}
<input type="radio" checked="checked" name="radio"
ng-model="selection" value="lbs">
<span class="checkmark"></span>
</label>
<label class="radio-container">{{ "Kilograms" | translate }}
<input type="radio" name="radio" ng-model="selection" value="kg">
<span class="checkmark"></span>
</label>
</div>
如何根据单选选择更改滑块的最小/最大值?我尝试使用 ng-if 但那是为了显示/隐藏 html。我还尝试在 app.controller 中添加一个 if 语句,但没有成功。
if ($scope.selection == 'lbs') {
weight_maximum = $this->weight_maximum;
} else if ($scope.selection == 'kg') {
weight_maximum = $this->weight_maximum / 2.2;
}