ng-repeat $ index to char in alphabet

时间:2014-01-10 10:45:40

标签: javascript angularjs

<script>var array_char = ["a", "b", "c", "d", "e", "f", "g",..., "z"];</script>

<tr ng-repeat="r in myModel">
     <td>{{$index}}</td>
     <td>{{char in alphatbet?}}</td> 
</tr>

我想要第二栏中的a,b,c ......我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:0)

请阅读以下文档:ng-repeatcontrollersapplication bootstrap

HTML:

<body ng-app="app">
    <table ng-controller="ctrl">
        <tr ng-repeat="r in myModel">
            <td>{{$index}}</td>
            <td>{{r}}</td>
        </tr>
    </table>
</body>

JS:

angular
.module("app", [])
.controller("ctrl", function($scope) {
    $scope.myModel = ["a", "b", "c", "d", "e", "f", "g", "z"];
});

JSBin