테스트 사이트 - 개발 중인 베타 버전입니다

개체로서의 데이터 소스

· 8년 전 · 1423
개체로서의 데이터 소스

이전 예제에서 데이터 소스는 배열 이었지만 객체를 사용할 수도 있습니다.

키 - 값 쌍이있는 객체가 있다고 가정합니다.

$scope.cars = {
car01 : "Ford",
car02 : "Fiat",
car03 : "Volvo"
};
ng-options속성 의 표현식은 객체에 대해 약간 다릅니다.


객체를 데이터 소스로 사용하면 x키를 y 나타내고 값을 나타냅니다.

<select ng-model="selectedCar" ng-options="x for (x, y) in cars">
</select>

<h1>You selected: {{selectedCar}}</h1>

선택한 값은 항상있을 것입니다 값 키 -의 값 쌍입니다.

값 의 키 - 값 쌍은 대상이 될 수있다 :


선택된 값은 계속 될 것이다 값 의 키 - 값 쌍 만이 시간은 그 목적으로한다 :

$scope.cars = {
car01 : {brand : "Ford", model : "Mustang", color : "red"},
car02 : {brand : "Fiat", model : "500", color : "white"},
car03 : {brand : "Volvo", model : "XC90", color : "black"}
};

드롭 다운 목록의 옵션이 될 필요가 없습니다 키 A의 키 - 값 쌍, 또한 값 또는 값 객체의 속성이 될 수 있습니다 :


<select ng-model="selectedCar" ng-options="y.brand for (x, y) in cars">
</select>

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

게시글 목록

번호 제목
1236
jQuery Mobile taphold event
1235
jQuery Mobile tap event
1234
jQuery Mobile swiperight event
1233
jQuery Mobile swipeleft event
1232
jQuery Mobile swipe event
1231
jQuery Mobile scrollstop event
1230
jQuery Mobile scrollstart event
1229
jQuery Mobile pageshow event
1228
jQuery Mobile pageremove event
1227
1226
1225
1224
1223
1222
1221
1220
1219
1218
1217
1216
1215
1214
1213
1212
1211
1210
1209
1208
1207