You probably want to import the whole ReactiveXJS package like this:
import 'rxjs/Rx';
On the other hand Observable.fromArray(arr: Array<any>)
is a static method - you can't use it on an instance. The documentation though says, that this method is deprecated and one should use Observable.from()
now.
Use it like so for instance:
//our root app component
import {Component} from '@angular/core';
import {Observable} from 'rxjs/Rx';
import 'rxjs/Rx';
@Component({
selector: 'my-app',
providers: [],
template: `
<div *ngFor="let item of output">{{item}}</div>
`,
directives: []
})
export class App {
ob: Observable<any>;
someArray: Array<number> = [ 1, 2, 3, 4, 5, 6, 7, 8 ];
output: Array<number> = [];
constructor() {
this.ob = Observable.from(this.someArray);
this.ob.subscribe((data) => {
this.output.push(data);
});
}
}