angular.js - 一个数组中有对象里面结构如下,用ng-options选择id,还想双向绑定在页面显示其中的分数字段score,如何修改?
阿神
阿神 2017-05-15 17:11:02
0
1
558

一个数组中有对象里面结构如下,用ng-options选择id,还想双向绑定在页面显示其中的分数字段score,如何修改?

阿神
阿神

闭关修行中......

reply all(1)
Ty80

Thanks for the invitation.
I can think of two methods for your data structure. One is not to use value.id as the value, but to use $index as the value. It will be easier to handle later.

The second method is to monitor the data changes of s_style, such as adding ng-change callbacks to select, and then using the new data directly in the page, for example.

$scope.change = ()=>{
    $scope.currentItem = $scope.arr.find(v => v.id === $scope.s_style);
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template