在调用方法来填充详细信息网格之前,如何从填充的下拉列表中获取信息
How do get information from a populated dropdownlist before calling a method to fill the details grid?
正确的方法是什么?这是一个接一个的语句,但由于javascript是异步的,我猜调用第二个函数时$score.lastItem不存在?那么我是否将第二个函数放在第一个函数的回调中?
//1st Call this on inital load to populate Congresses dropdownlist
ccResource.query(function (data) {
$scope.ccList.length = 0;
angular.forEach(data, function (ccData) {
$scope.ccList.push(ccData);
})
$scope.lastItem = $scope.ccList[$scope.ccList.length - 1];
});
//2nd after populating $scope.lastItem run this to populate grid on initial load (using id from selected item in dropdownlist)
cgResource.query({ id: $scope.lastItem.congressNumber }, function (data) {
$scope.usersList = data;
});
//ngGrid
$scope.userGrid = {
data: 'usersList',
multiSelect: false,
selectedItems: $scope.selectedUsers,
enableColumnResize: false,
columnDefs: [
{ field: 'firstname', displayName: 'First Name', width: '25%' },
{ field: 'lastname', displayName: 'Last Name', width: '25%' }
]
};
是的。你可以做
//1st Call this on inital load to populate Congresses dropdownlist
ccResource.query(function (data) {
$scope.ccList.length = 0;
angular.forEach(data, function (ccData) {
$scope.ccList.push(ccData);
})
$scope.lastItem = $scope.ccList[$scope.ccList.length - 1];
//2nd after populating $scope.lastItem run this to populate grid on initial load (using id from selected item in dropdownlist)
cgResource.query({
id: $scope.lastItem.congressNumber
}, function (data) {
$scope.usersList = data;
});
});
相关文章:
- 无法使用国家/地区选择中的状态动态填充下拉列表
- 通过使用AngularJs进行分组来填充下拉列表
- 如何填充下拉列表,从javascript中的另一个下拉列表中排除任何一个选项
- 使用 MySQL 条目填充下拉列表
- 如何使用其他下拉列表中未选择的选项填充下拉列表
- 使用jquery动态填充下拉列表
- 在AngularJS中动态填充下拉列表
- 使用数据库返回的数据动态填充下拉列表
- 设置 AJAX 调用和填充下拉列表
- 使用 ajax 和 JSP Servlet 根据选择的上一个下拉列表填充下拉列表
- 在 JavaScript 中使用 MySQL 数据库中的数据填充下拉列表
- 如何在 jQuery 中用 JSON 数据填充下拉列表作为 ajax 响应
- 使用 ajax 用 SQL 填充下拉列表
- 如何使用 JavaScript 中的值填充下拉列表
- 如何在信息窗口中填充下拉列表(谷歌地图API v3)
- 从 Javascript 和 Java 返回的数组中填充下拉列表
- 使用 AJAX 和 ORACLE 以及不使用 php 填充下拉列表(选择 )
- 单击第一项时重新填充下拉列表
- 尝试使用 jquery 和 ajax 填充下拉列表
- 如何使用 javascript 清空下拉列表后重新填充下拉列表