Encountering an unusual problem with setting the ng-model
for a select drop-down menu.
Despite using a property value that matches one in the ng-options
, the ng-model
consistently ends up as null
.
Below is the function responsible for fetching orders:
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);
}
});
Review of pagerService.data can be seen here: https://i.sstatic.net/WcppO.png
The value of
order.orderShippingMethod[0].shippingMethod
is:
{"shippingMethodId":7,"carrierName":"Russian Post","carrierUrl":"http://www.russianpost.ru/tracking20/English.htm","orderShippingMethod":[]}
The options for the select list are available: https://i.sstatic.net/ENmYs.png
Your input and suggestions are appreciated. As someone new to AngularJs, I believe it's a simple oversight on my part!
<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>