简体   繁体   English

我可以使用通过ng-model输入的值来填充角度ng网格吗?

[英]Can I use entered value through ng-model to populate angular ng grid?

This plunker populates a static Html Table correctly based on a search for 'Tim' (Json Data). 根据对“ Tim”(Json数据)的搜索,此插件会正确填充静态HTML表。

    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

        });

Now I want to place this data in a NG-Grid. 现在,我要将这些数据放置在NG-Grid中。
This plunker attempts to load this data into NG Grid based on a Tim Search. 插件会尝试根据Tim搜索将数据加载到NG Grid中。 I tried so many ways to do this. 我尝试了很多方法来做到这一点。 Now I'm trying to assign arrItem to $scope.source and pass that into getPagedDataAsync. 现在,我尝试将arrItem分配给$ scope.source并将其传递给getPagedDataAsync。 Any ideas? 有任何想法吗?

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

In your controller, where you define the gridOptions, you are using the wrong scope variable name. 在控制器中定义gridOptions的位置,使用了错误的作用域变量名称。

 data: 'myData',

should be 应该

 data: 'source',

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

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