来自控制器的多个数据

时间:2015-11-17 11:39:15

标签: angularjs ionic-framework ionic

我试图在从控制器到同一项目的数据上显示更多信息。如果我想在ng-repeat中设置另一个条件="文件在fileno&描述&中的filedet statusno"中的状态该项目未显示

控制器

.controller('caseFileCtrl', function($scope) {
    $scope.fileno = ["1", "2", "3"];
    $scope.descript = ["consumer", "litrel", "accident"];
    $scope.statusno = ["open", "closed", "closed"];
})

查看

<ion-list>
    <ion-item item-icon-right href="#/filedetails" ng-repeat="file in fileno">File Ref No:{{file}}
        <br> Description:{{filedetail}}
        <br> Status:{{status}}
    </ion-item>
</ion-list>

1 个答案:

答案 0 :(得分:2)

您可以通过相应的索引来引用项目:

<ion-item item-icon-right href="#/filedetails" ng-repeat= "file in fileno">
    File Ref No: {{file}}<br>
    Description: {{desript[$index]}}<br>
    Status: {{statusno[$index]}}
</ion-item>

但理想情况下,您修改数据结构以使用对象数组而不是三个单独的数组:

.controller('caseFileCtrl', function ($scope) {
    $scope.files = [
        {number: "1", description: "consumer", status: "open"},
        {number: "2", description: "literl", status: "closed"},
        {number: "3", description: "accident", status: "closed"}
    ];
});

并像这样使用它:

<ion-item item-icon-right href="#/filedetails" ng-repeat= "file in files">
    File Ref No: {{file.number}}<br>
    Description: {{file.desription}}<br>
    Status: {{file.status}}
</ion-item>