0

다음 코드는 id에 대한 옵션 이름을 수행합니다.선택한 ng-options 옵션의 이름을 사용자 지정 이름으로 변경할 수 있습니까?

<select ng-model="vm.ships" ng-change="vm.updateShip()" data-ng-options="ship as ship._id for ship in vm.readyships"> 

Q는 : 어떻게 이름이 뭔가 할 수 있습니다 "배 ship.id은 (ship.to) 준비가?"

도 ng-options로 할 수 있습니까?

는 결과를 원 :

<option value="0" selected="selected" label="57e261">ship 57e261 is ready (sweden) </option> 

업데이트 : toarray의 일부인 경우

변수 ship.to

답변

1

data-ng-options의 레이블 부분에서 이미 원하는 작업을 수행하고 있습니다. 당신이 추가 텍스트에 연결할 수 있습니다 전체 라벨 얻기 위하여 : 문서에 추가

<select ng-model="vm.ships" ng-change="vm.updateShip()" data-ng-options="ship as ('ship' + ship._id + ' is ready (' + ship.to + ')') for ship in vm.readyships"> 

을,이 previous answer 금액은 다른 옵션까지 당신은 ng-options에 있습니다.

0

그것의 가능한 사용 가능한입니다.

ng-options="obj as obj.to for obj in results" 
+0

은 그래서 선박 ID가에 준비가 표시됩니다? – maria

0

ship.to 가정이 존재합니다

<select ng-model="vm.ships" ng-change="vm.updateShip()" data-ng-options="ship as ship._id + ' is ready (' + ship.to + ')' for ship in vm.readyships">