2014-10-17 2 views
0

NG-모델리스트 객체를 설정하지 않습니다에 의해 트랙 선택 초기화 data.data_source에 내가AngularJS와 내가 선택을 가지고

{id:"myid"} 

올바른 값이 선택에 표시됩니다 DB를에서하지만 내 NG 모델 I의 시간에 검색 할 개체를 포함 'id'속성 만 가진 내 원래 data_source 객체를 보겠습니다. 여기에 모든 속성 (이름 및 기타)이있는 data_sources 배열에서 오는 객체가 있습니다. 그렇게 할 방법이 있습니까?

+0

'NG-model' 선택한 값이 저장되어있는'$ scope' 변수가 아니라 당신이 'NG-options'에서 사용하는 데이터 배열이 아래 방식으로 DATA_SOURCE를 업데이트 할 수 있습니다 초기화에 . –

답변

0

드롭 다운 변경시 ng 모델이 자동으로 모든 속성으로 업데이트됩니다. 당신이

data.data_source = dataFromSever 
data_sources = dataListFromServer 
//now get the matched obj of data_sources array by matching data_source.id 
//set data_source = matchedObj.. This will ensure the correct structure of model at init