我可以使用通过 ng-model 输入的值来填充角度 ng 网格吗? [英] Can I use entered value through ng-model to populate angular ng grid?

查看:24
本文介绍了我可以使用通过 ng-model 输入的值来填充角度 ng 网格吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

plunker 根据对Tim"的搜索正确填充静态 Html 表(Json 数据).

This plunker populates a static Html Table correctly based on a search for 'Tim' (Json Data).

    var arrItem = [];
    angular.forEach($scope.items, function (item) {
    if(item.fname === enteredValue.firstName || item.lname === enteredValue.lastName
    ||item.address === enteredValue.address && item.phone === enteredValue.phone){
        arrItem.push({
            first: item.fname,
            last: item.lname,
            address: item.address,
            phone: item.phone

        });

现在我想把这些数据放在一个 NG-Grid 中.
这个 plunker 尝试根据 Tim 搜索将此数据加载到 NG 网格中.我尝试了很多方法来做到这一点.现在我试图将 arrItem 分配给 $scope.source 并将其传递给 getPagedDataAsync.有什么想法吗?

Now I want to place this data in a NG-Grid.
This plunker attempts to load this data into NG Grid based on a Tim Search. I tried so many ways to do this. Now I'm trying to assign arrItem to $scope.source and pass that into getPagedDataAsync. Any ideas?

  $scope.source= arrItem;
  $scope.getPagedDataAsync($scope.source, $scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage); 

推荐答案

在您定义 gridOptions 的控制器中,您使用了错误的范围变量名称.

In your controller, where you define the gridOptions, you are using the wrong scope variable name.

 data: 'myData',

应该

 data: 'source',

这篇关于我可以使用通过 ng-model 输入的值来填充角度 ng 网格吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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