【问题标题】:Can I use entered value through ng-model to populate angular ng grid?我可以使用通过 ng-model 输入的值来填充角度 ng 网格吗?
【发布时间】:2015-07-01 00:13:44
【问题描述】:

plunker 根据对“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

        });

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

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

【问题讨论】:

    标签: javascript json angularjs angularjs-scope ng-grid


    【解决方案1】:

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

     data: 'myData',
    

    应该是

     data: 'source',
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多