3
我正在使用Angular UI網格,並嘗試保存網格狀態時發生錯誤。 gridApi似乎是未定義的。 我創建了一個plunkr http://plnkr.co/edit/1gC9Z5nP1FB0NLHCEuCF?p=preview來演示錯誤。您可以在vm.saveState函數下的View2Controller.js中找到該語句。當嘗試保存狀態時,角UI網格gridApi未定義
angular.module('app').controller('View2Controller').$inject = ['$scope', '$http', 'uigridconstants'];
angular.module( '應用')控制器( 'View2Controller',函數($範圍,$ HTTP,uiGridConstants){ VAR VM =此;
vm.customers = [];
vm.selectedText = '';
vm.selectedItems = [];
vm.gridOptions = {
onRegisterApi: function (gridApi) {
$scope.gridApi = gridApi;
},
data: 'vm.customers',
columnDefs: [
{
field: 'status', name: '', width: 50, sort: {
direction: uiGridConstants.DESC,
priority: 0
}
},
{
field: 'member', name: 'M', width: 50, type: 'boolean',
cellTemplate: '<input type="checkbox" ng-model="row.entity.lid" >'
},
{
field: 'company', name: 'Company', width: 200, minWidth: 200, maxWidth: 600
}
]
};
$http.get('customers.json')
.success(function (data) {
vm.customers = data;
});
vm.saveState = function(){
//debugger;
var stateToSave = $scope.gridApi.saveState.save();
console.log(stateToSave);
};
})。
非常感謝您的任何幫助。