i am unable to assign data to my qMList. console always showing that list is undefined. web service is working and data is coming as observable problem is data not assigning to qMList.
@Injectable()
export class QuestionService {
public qMList: QuestionMaster[] ;
constructor(private http: HttpClient) {
}
getOsz():Observable<QuestionMaster[]>{
return this.http.get<QuestionMaster[]>("http://localhost:7073/api/values");
}
getQuestions() {
this.getOsz().subscribe(res => this.qMList = res);
console.log(this.qMList);
}
}
qMListhas been setconsole.loginto the subscribe, it'll print fine (subscribe(res => { this.qMList = res; console.log(this.qMList);}))