2014-11-01 50 views
0

我創建這裏plunkr:http://plnkr.co/edit/wPCex3lJc5E0I4fSeXI1?p=previewAngularJS - For循環,推動整個對象不僅僅是標題

應用程序應該允許用戶執行搜索,並返回結果。

我已經到了顯示正確結果的數量(如果只是一個國家被選中)的地步,但我似乎無法通過我for循環中的整個匹配對象。

HTML:

<div ng-repeat="myresults in Results track by $index"> 

    {{myresults}} 

</div> 

JS:

$scope.Results = []; 

$scope.search = function(country, city, department) { 
    var countryValue = country.Country; 
    for (i = 0; i < $scope.Data.length; i++) { 

     if ($scope.Data[i].Country == countryValue) { 
     $scope.Results.push(countryValue); 
     } 
    } 

    console.log($scope.Results); 
    } 

回答

相關問題