从后台传map到前台进行处理

1 后台查询等级和该等级下的项目

Map> trainingMap=new HashMap<>();
        //查询所有项目
        List trainingLevel=trainingProgramDao.queryAllLevel();

        for(TrainingModel trainingModel:trainingLevel){
            if(trainingMap.containsKey(trainingModel.getLevelOrder())){
                trainingMap.get(trainingModel.getLevelOrder()).add(trainingModel);
            }else {
                List trainingModels = new ArrayList<>();
                trainingModels.add(trainingModel);
                trainingMap.put(trainingModel.getLevelOrder(),trainingModels);
            }
        }
        return trainingMap;

2.前台获得等级

 let url='http://192.168.22.126/second-training-web/trainingProgram/queryPrograms';
    this.http.get(url).subscribe(
      res=>{
        //console.log(res.json())
        this.programs=res.json()
        
        for(var k in this.programs){
           this.levelOrder.push(k);
        }
      },
      error=>{
        console.log(error);
      }
    ) 

获得等级所有项目,获得value值

   this.program =this.programs[item];

你可能感兴趣的:(从后台传map到前台进行处理)