我试图获取切换的值,但在检查它工作正常后第一次点击未选中的切换按钮时它不起作用。
<ul class="list has-header">
<li class="item item-toggle" ng-repeat="ingr in ingredients|filter:searching">
{{ingr.INGREDIENTNAME}}
<label class="toggle toggle-energized" >
<input type="checkbox" ng-model="ingr.INGREDIENTSTATUS" ng-change='changeingrStatus(ingr.INGREDIENTCODE,ingr.INGREDIENTSTATUS)' ng-checked="{{ingr.INGREDIENTSTATUS==1?true:false}}">
<div class="track">
<div class="handle"></div>
</div>
</label>
</li>
</ul>
Controller .js
$scope.changeingrStatus = function(code, status) {
console.log(status);
}
最佳答案
您不能将 ng-model
属性与 ng-checked
一起使用。我建议仅使用 ng-model
。
阅读ngChecked详情页面:
Note that this directive should not be used together with
ngModel
, as this can lead to unexpected behavior.
关于javascript - 选择切换按钮取消选择时,第一次不会触发 Ionic ng-change,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41937403/