简体   繁体   English

带有$ http服务数据的ui-grid(ng-grid)

[英]ui-grid (ng-grid) with $http service data

I am trying to fetch all the data from the server at once and then display the paginated data using ui-grid. 我试图一次从服务器获取所有数据,然后使用ui-grid显示分页的数据。

Here is what I did in my controller: 这是我在控制器中所做的:

        $scope.myData = [];
        $http.get($rootScope.app.authApi + 'questions/' + selectedSubtopic.id).then(function (data) {
            $scope.myData = data;
        });

And in my html: 在我的html中:

<div ui-grid="{ data: myData }" class="myGrid"></div>

I keep getting this kind of error: 我不断收到这种错误:

在此处输入图片说明

I have got the same error.By looking at $http.get() result I found out that it's not an array but it's an object that has data as one of its members .So this should work : 我有同样的错误。通过查看$ http.get()结果,我发现它不是数组,而是一个具有数据作为其成员之一的对象,因此这应该可以工作:

 $scope.myData = [];
        $http.get($rootScope.app.authApi + 'questions/' + selectedSubtopic.id).then(function (result) {
            $scope.myData = result.data;
        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM