在 Set 上使用 ngrepeat

ple*_*dez 4 angularjs ng-repeat angularjs-ng-repeat

我有一个 vm.s = new Set([1,2,3])

如何ngRepeats不将其转换为数组的情况下使用?

我试过了

<option ng-repeat="o in vm.s">{{o}}</option>
<option ng-repeat="o in vm.s.values()">{{o}}</option>
<option ng-repeat="o in Array.from(vm.s)">{{o}}</option>
Run Code Online (Sandbox Code Playgroud)

ale*_*mav 5

Set() 是 EMCAScript 6 的一项功能。Angular 1.x 不直接支持 ES6 特性。Array.from(vm.s)应该为你工作。