0
할당 된 ID를 기반으로 어레이의 표현식을 인쇄하려면 어떻게해야합니까? 두 개의 배열이 있습니다. 하나는 id가 11이고 다른 하나는 12입니다. 어떻게 12의 속성을 가진 배열의 이름 표현식을 얻을 수 있습니까? 다음은 각도 Js : ID를 기반으로 배열에서 표현식을 선택하려면 어떻게해야합니까?
는 서비스 모듈, 컨트롤러 및 HTMLhttp://jsfiddle.net/ADukg/4705/
var myApp = angular.module('myApp',[]);
function MyCtrl($scope, myProperties) {
$scope.name = 'StackOverflow';
$scope.myProperties = myProperties;
};
myApp.factory('myProperties', function() {
var myProperties = [
{
'name': '3 Bedroom Fixer Upper',
'city': 'Santa Rosa',
'id': 11,
'state': 'CA',
'date_added': '2/3/14',
'completion_status': '80%',
'imgURL': 'http://dfon12yb6dcdf.cloudfront.net/product/kr4f0uv5tkd6slvmn7r9j4h4jj/w1024x683.jpg?v=4',
},
{
'name': '2 Bedroom Condo',
'city': 'Vallejo',
'id': 12,
'state': 'CA',
'date_added': '4/10/20',
'completion_status': '50%',
'imgURL': 'http://dfon12yb6dcdf.cloudfront.net/product/kr4f0uv5tkd6slvmn7r9j4h4jj/w1024x683.jpg?v=4',
},
]
//return the array here
return myProperties
});
<div ng-controller="MyCtrl">
<h1>Hello, {{name}}!</h1>
<br>
<ul ng-repeat="property in myProperties">
<li>{{property.name}}</li>
</ul>
<br>
<h3>{{property.id[12]}}</h3>
</div>