javascript - How to get the return filter array data in angular js controller? -
i'm using custom filter application.
div class="cust-post" ng-repeat="post in newsfeeddata | customfilter:companyfilters"
in above code customfilter return array data need use array data controller.
i don't know how retrieve array data.
anyone please assist me.
try as
keyword within ng-repeat
, can access filtered array via $scope.array
:
angular.module('app', []) .controller('ctrl', ['$scope', function($scope) { $scope.items=[ {name:'a'}, {name:'ba'}, {name:'cb'}, ]; $scope.test = function() { $scope.out = $scope.array.map(x => x.name).join(', '); } }])
<script src="//code.angularjs.org/snapshot/angular.min.js"></script> <div ng-app='app' ng-controller="ctrl"> <input type='text' ng-model='search' ng-init='search = "a"'/> <ul> <li ng-repeat='item in items | filter: search array'>{{item}}</li> </ul> <input type='button' ng-click='test()' value='test'/> <hr/> {{out}} </div>
Comments
Post a Comment