var oList = []; getFooterList( vm.searchParam ,platType,type); function getFooterList(parmas,platType,type){ managerService.getFooterList(parmas,platType,type).then(function(res){ vm.list=res.data.objs; angular.forEach(vm.list, function(item, index){ if(item.type == 5) oList.push(item); vm.item = oList; console.log(vm.item) }); console.log(res) }) }
我在调接口的时候遇到这个问题:只想让type=5的数组进行展示,然后ng-repect="li in vm.list " {{li.title}}
这最好是后端给定一个链接,但是没有的情况下:
angular.forEach(vm.list, function(item, index) 这个是对vm.list进行遍历 vm.list=res.data.objs下有10个数组,对这10个数组进行遍历,后边的item 是参数,这个item代表了每个小数组item.type==5就是ltem下type=5的话,就把这个item小数组推送到
上边定义好的oList这个大数组中。
之后在html中对这个li in vm.item 就可以了
不过方便的还是找后端去。。。