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

개체로서의 데이터 소스

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

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

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

$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>

댓글 작성

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

로그인하기

게시글 목록

번호 제목
1266
1265
1264
1263
1262
1261
1260
1259
1258
1257
1256
jQuery Mobile Button Refresh()
1255
1254
1253
1252
1251
1250
1249
1248
jQuery Mobile Button Widget 1
1247
jQuery Mobile Checkbox 속성
1246
jQuery Mobile Button 속성
1245
jQuery Mobile vmouseup event
1244
jQuery Mobile vmouseover event
1243
jQuery Mobile vmouseout event
1242
jQuery Mobile vmousemove event
1241
jQuery Mobile vmousedown event
1240
jQuery Mobile vmousecancel event
1239
jQuery Mobile vclick event
1238
jQuery Mobile updatelayout event
1237