AngularJS - 将$ index显示为char

use*_*790 0 javascript jquery json angularjs

我有一个ng-repeat,它重复了两个<li>特定的时间.我也在使用它$index来查看输出的索引<li>.

一个样本就在这个小提琴上:http://jsfiddle.net/sh0ber/cHQLH

但是,<li>在使用索引而不是输出1,2,3等数字时,我需要其中一个,它输出字母如A,B,C等.

有没有办法在AngularJS中做到这一点?我是新来的.

编辑:

我需要输出的方式如下:C1,C2,C3 ...... B1,B2,B3 .... A1,A2,A3 ......

即字母下降.

谢谢

Eng*_*eer 5

你可以写一个过滤器:

.filter('character',function(){
    return function(input){
        return String.fromCharCode(64 + parseInt(input,10));
    };
});
Run Code Online (Sandbox Code Playgroud)

并使用它:

{{$index+1|character}}
Run Code Online (Sandbox Code Playgroud)

DEMO