Unable to load data inside ngOnInit

前端 未结 4 825
感情败类
感情败类 2021-01-26 10:31

My goal is to load a dropdown when a component renders. I have a service which hits a url and gets json data. Something like this

 @Injectable()
 export class St         


        
4条回答
  •  没有蜡笔的小新
    2021-01-26 11:01

    ngOnInit() {
           setTimeout(()=>
              {
                this.studentListService.getStudent().subscribe(response =>{
                 this.items = response;
              },error=>{
               console.log(error);
             });
         },1000);
     }
    

提交回复
热议问题