I'm trying to return an array from this TypeScript function (written within Angular).
I've tried a number of different approaches. I've tried having a public variable in the class that gets initialized with courses (say the variable was called public fallCourses : xCourse[] and in the function below it'd have this.fallCourses = courses), I've tried typing return before 'courses' within the function call below, etc. Pretty simple operation, just can't get it to work.
getFallCourses(){
let fallCourses : xCourse[];
this.dataService.getFallCourses().subscribe((courses: xCourse[]) => {
fallCourses = courses;
});
return fallCourses;
}