0
我有這個相當奇怪的問題,爲選擇下拉列表設置ng-model
。AngularJs - 從集合屬性設置模型
我使用ng-model
的屬性值似乎匹配在ng-options
但ng-model
條目最終總是爲null
。
這是獲得訂單的方法:
orderService.getMerchantOrders(qs)
.then(
function (response) {
$scope.isLoading = false;
$scope.pagerService = new pagerService({
page: $scope.pagerService.page,
data: response.data.items,
total: response.data.total,
sortVars: response.data.sort,
pageSize: 5
});
},
function (error) {
if (error.status === 401) {
$window.location.href = $scope.returnUrl;
} else {
//show error message
console.log(error);
}
});
的order.orderShippingMethod[0].shippingMethod
值是:
{"shippingMethodId":7,"carrierName":"Russian Post","carrierUrl":"http://www.russianpost.ru/tracking20/English.htm","orderShippingMethod":[]}
感謝您的任何想法。我非常喜歡AngularJs所以我覺得這很簡單我很想念這裏!
<select class="form-control" name="carrierList"
ng-model="order.orderShippingMethod[0].shippingMethod"
ng-options="shippingMethod.shippingMethodId as shippingMethod.carrierName
for shippingMethod in shippingMethods" required>
<option value="">Select Carrier</option>
</select>
您應該添加一些代碼,說明您目前圍繞您提供的代碼段的內容。您應該顯示$ scope.order的定義位置,以及$ scope.order.orderShippingMethod(s)的定義位置。 – alexhuang
好主意,更新了更多細節! –