吴格无法设置的未定义的属性'gridDim“ [英] Ng-grid Cannot set property 'gridDim' of undefined

查看:645
本文介绍了吴格无法设置的未定义的属性'gridDim“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在新的角度,我尝试申报NG-电网gridOption在在costroller的功能。

这导致错误:

类型错误:无法设置属性gridDim未定义

我试着使用$ scope.apply和NG-如果模板来解决它。但是从这个没有什么工作对我来说。

感谢您的任何意见:

控制器的方法:

  $ scope.getTest =功能(){    $ http.get('http://www.iNorthwind.com/Service1.svc/getAllCustomers')
    .success(功能(数据,状态,头,配置){
            //$scope.myData =数据;
            的console.log('Sucess'+数据);
            //定义NG-网格表
            $ scope.myData = [{名:莫罗尼,年龄:50},
                             {名:Tiancum,年龄:43},
                             {名:雅各布,年龄:27},
                             {名:尼,年龄:29},
                             {名:挪,年龄:34}];
            $ scope.gridOptions = {数据:myData的'};
            // $范围$适用();
    })
    .error(功能(数据,状态,头,配置){
            $ scope.myData =数据;
    });};


解决方案

我只是碰到了这个问题昨天....

为了最初呈现, NG-格需最初提供的选项,而不是之后你的 $ HTTP 承诺得到解决。

移动你的 $ scope.gridOptions = {数据:myData的'} 呼叫你成功的承诺之外,你的问题应该走

I'm new in Angular, and I try to declare gridOption for ng-grid Within a function in costroller.

It cause an error:

TypeError: Cannot set property 'gridDim' of undefined

I tried to solve it using $scope.apply and ng-if in template. But nothing from this is working for me.

Thanks for any advice:

method of the Controller:

$scope.getTest = function() {

    $http.get('http://www.iNorthwind.com/Service1.svc/getAllCustomers')
    .success(function (data, status, headers, config) {
            //$scope.myData = data;
            console.log('Sucess' + data);
            // definition for ng-grid table 
            $scope.myData = [{ name: "Moroni", age: 50 },
                             { name: "Tiancum", age: 43 },
                             { name: "Jacob", age: 27 },
                             { name: "Nephi", age: 29 },
                             { name: "Enos", age: 34}];
            $scope.gridOptions = { data: 'myData' };
            //$scope.$apply();
    })
    .error(function(data, status, headers, config) {
            $scope.myData = data;
    });

};

解决方案

I just ran into this issue yesterday....

In order to initially render, ng-grid needs the options to be supplied initially, not after your $http promise is resolved.

Move your $scope.gridOptions = { data: 'myData' } call outside of your success promise and your issue should go away.

这篇关于吴格无法设置的未定义的属性'gridDim“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆