Subscribe is not a function error

You should return an observable , instead you are returning an array:

For Angular <= 5.x.x

getBanners(): Observable<any[]> {
    return Observable.of(this.banners);
}

For Angular >= 6.x.x

getBanners(): Observable<any[]> {
    return of(this.banners);
}

Reference


A couple of things to fix.

  1. You declare that your function getBanners() returns an Observable, but you return an array. So change your return statement to

    return Observable.from(this.banners);

You'll also need to add this:

import 'rxjs/add/observable/from'; 
  1. This is bad practice and will include the entire rxjs library into your code:

    import { Observable } from 'rxjs';

Import only what you need. Replace the above with

import { Observable } from 'rxjs/Observable';