在最初调用获取项目列表(见下文)之后,我需要选择第一个项目并从我的数据库中获取更多详细信息。因此,在项目加载到我的选择输入后,我需要:
- 突出显示列表框中的第一项
- 首先将其传递
itemID
给 DB 以获取该项目的详细信息。
如何在初始页面加载中完成所有这些操作?
<!DOCTYPE html>
<html>
<head>
<script src="Scripts/angular.js"></script>
<script src="Scripts/angular-resource.js"></script>
<script>
var IM_Mod_app = angular.module('IM_ng_app', []);
IM_Mod_app.controller("IM_Ctrl", function ($scope, $http) {
var PlaId = "DFC";
$http({
method: 'GET',
url: 'http://xxx/api/ItemMaintenance/GetAllFilteredItems',
params: { PlaId: PlaId }
}).then(function successCallback(response) {
$scope.items = response.data;
}, function errorCallback(response) { });
});
</script>
</head>
<body ng-app="IM_ng_app">
<table ng-controller="IM_Ctrl">
<tr>
<td>
@*<select ng-model="itm" size="10" ng-options="itm.ITEM_ID for itm in items" ng-class="{selected: $index==0}" ng-change="onItemSelected(itm.ITEM_ID)">*@
@*<select ng-model="itm" size="10" ng-options="itm.ITEM_ID for itm in items track by itm.ITEM_ID" ng-selected="$first" >*@
<select ng-model="itm" size="10" ng-options="itm.ITEM_ID for itm in items track by itm.ITEM_ID" ng-init="items[0].ITEM_ID">
<option value="" ng-if="false"></option>
</select>
</td>
</tr>
</table>
</body>
</html>