我一直在使用这样的索引值:
{{ $index }}
我真正需要的不是获取一个数字,而是获取一个从 A 到 Z 的大写字符。应该没有字符用完的问题,因为我最多只有 10 个重复的东西。
谁能告诉我该怎么做?
最佳答案
将以下方法添加到您的范围:
$scope.indexChar = function (index) {
return String.fromCharCode(65 + index);
};
然后在你的 View 中使用它:
{{ indexChar($index) }}
这是 fiddle :http://jsfiddle.net/Xs5Qn/
关于javascript - 如何使用 data-ng-repeat 获取从 A 到 Z 的索引值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18815280/