Using the following service to set result to this.temp, console log shows the result when inside the subscribe, but returns undefined when outside.
1) this.http.get('../../assets/students.json').subscribe((data)=>{
2) this.temp = data;
3) console.log(data);//shows result
4) console.log(this.temp);//shows result
5) })
6) console.log(this.temp);//undefined
but in the console line, 6 is outputted first and then 3 and 4