4
개체 배열에서 하나의 개체 속성의 모든 인스턴스를 표시하는 각도 목록을 원합니다. 예를 들어 국가 만 추가 할 수도 있습니다.개체 배열의 한 속성 만 나열하십시오.
$scope.testSites = [
{ "site": "Testsite1", "country": "Country1", "customer": "Customer1"},
{ "site": "Testsite2", "country": "Country2", "customer": "Customer2"}
];
$scope.chosenCategory = 1;
$scope.categoryNames = ["site", "country", "customer"];
$scope.aspect = $scope.categoryNames[$scope.chosenCategory];
그러나 위의 변수 'aspect'를 사용하여 목록에 표시 할 속성을 선택하고 싶습니다. {{x.country}}와 같은 것이 작동하기는하지만 충분하지 않습니다. 이것을 시도했지만 빈 목록을 반환합니다.
<table border="1" class="list-group-item list-group-item-success">
<tr>
<th>{{aspect | capitalize}}</th>
</tr>
<tr ng-repeat="x in testSites | orderBy:myOrderBy">
<td>
{{x.aspect}}
</td>
</tr>
</table>
내가 할 수 있는게 있습니까?
Demo here 글쎄 데모 – Zooly
감사 작업 https://plnkr.co/edit/7RgiUUp1JGHxi5vMc5np 찾을 수 있습니다. 대답에 넣을 수 있을까요? –
확실히, 당신은 트릭을 발견했습니다 :) – Zooly