옵션 바인딩에서 선택한 값을 가져 오지 못했습니다.녹아웃 옵션 바인딩 값 가져 오기
public class Organization
{
public int OrganizationId { get; set; }
public string Name { get; set; }
public string SapId { get; set; }
public string UserId { get; set; }
public bool Deleted { get; set; }
public ICollection<OrganizationAddress> OrganizationAddresses { get; set; }
}
뷰 모델 C# 모델 : 각 조직은 adresses의 ICollection이있다
<div data-bind="foreach:organizations" class="accordion " id="accordionOrg">
[...]
<table>
<thead>
<tr>
<th>Billing Address</th>
[...]
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<select data-bind="options: organizationAddresses, optionsText: 'address', value:'organizationAddressId'"></select>
</td>
<td>
<div data-bind="click: $root.addOrg" class="btn btn-small btn-block"></div>
</td>
</tr>
</tbody>
</table>
</div>
HTML : 여기
은 (간체) 코드의var organizations = ko.observableArray();
var vm = {
organizations: organizations,
activate: activate
};
return vm;
function addOrg(organization) {
//here I need the selected value
}
모든 것이 작동합니다. 나는 선택한 값을 얻는 방법을 모른다. 도움을 주시면 감사하겠습니다.
한마디로, 'organizationAddressId'에 대한'optionsValue' 바인딩 매개 변수를 사용하려고합니다. 값과 값을 모두 참조하십시오 ... 하나의 주소 또는 여러 주소를 원하십니까? – Origineil
혼란에 사과드립니다. 나는 하나의 주소를 원한다. 내 애플 리케이션에서 사용자가 여러 주소 (청구, 배달 등)를 선택할 수있는 '값'을 참조했습니다.