可以使用 ng-grid afterSelectionChange 返回值???
我怎样才能完成它?我想获得 $scope.programEdit 值,
setPagingData 函数设置数据显示在视图上,
getPagedDataAsync 函数使用 $resource 获取价值
任何人的想法?
请帮忙
$scope.setPagingData = function(data, page, pageSize, type){
var array = [];
for(var key in data){
if(!data.hasOwnProperty(key)){
continue;
}
array.push(key, data[key])
}
if(type == 0){
var a = array.slice(1,4);
$scope.myData = a[0];
}else{
var a = array.slice(1);
$scope.myData = a;
}
$scope.totalServerItems = data.length;
if (!$scope.$$phase) {
$scope.$apply();
}
return $scope.myData
};
$scope.getPagedDataAsync = function (pageSize, page, searchText, type) {
setTimeout(function () {
var data;
programService.query({
page: page
}, function (result) {
data = {
'program': result
};
$scope.setPagingData(data,page,pageSize,0)
return data
});
}, 100);
};
$scope.gridOptions = {
data: 'myData',
enablePaging: true,
showFooter: true,
totalServerItems:'totalServerItems',
pagingOptions: $scope.pagingOptions,
filterOptions: $scope.filterOptions,
selectedItems: $scope.mySelections,
multiSelect: false,
afterSelectionChange: function ($routeParams, $location, programService) {
$scope.program = $scope.mySelections[0];
var id = $scope.mySelections[0].programId;
if ($scope.mySelections[0].programId) {
$scope.programEdit = {
'program': programService.get({
page: 1,
id: $scope.mySelections[0].programId
})};
}
}
};
我想让它显示在编辑 html 上
<form ng-submit="save()">
<input type="hidden" ng-model="programEdit.programId"/>
<dl>
<dt>Program Name</dt>
<dd><input name="programName" type="text" ng-model="programEdit.programName"/></dd>
</dl>
<div class="form-actions">
<button type="submit">Save</button>
</div>
</form>