angular.forEach在调接口中的应用

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  就可以了
不过方便的还是找后端去。。。







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值