AngularJS - 在ng-repeat和切片内的ng-switch

时间:2014-08-19 10:55:33

标签: angularjs angularjs-scope angularjs-ng-repeat ng-switch

我有一个简单的ng-repeat循环遍历带有财务存款列表的JSON文件。

但是,我正在尝试对前12个条目进行切片并对值执行ng-switch:

HTML:

<td ng-repeat="deposit in MyData.MyDeposits.slice(0, 12)" ng-switch="WHATGOESHERE?">
    <span ng-switch-when="0">U</span>
    <span ng-switch-when="1">D</span>
    <span ng-switch-when="2">2</span>
    <span ng-switch-when="3">3</span>
    <span ng-switch-when="4" class="icon-warning">3</span>
</td>

JS:

function EventController($scope) {
    $scope.MyData = {
        "Name" : "Mr White",
        "MyDeposits": [
                "0",
                "0",
                "0",
                "U",
                "1",
                "2",
                "4",
                "0",
                "D",
                " ",
                " ",
                " ",
                " ",
                " ",
                " ",
                " ",
                " ",
                " ",
                " ",
                " ",
                " ",
                " "
         ];
    }
};

我面临的问题是我在ng-switch="WHATGOESHERE?"

中放置了什么

添加了plunker:http://plnkr.co/edit/WtFWVYVvRKm1pN19qlX8?p=preview

0 个答案:

没有答案