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

廉价感情. 提交于 2020-04-30 14:27:40

问题


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

        });

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); 

回答1:


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

 data: 'myData',

should be

 data: 'source',


来源:https://stackoverflow.com/questions/31150593/can-i-use-entered-value-through-ng-model-to-populate-angular-ng-grid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!