Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property 'from' does not exist on type 'typeof Observable', angular 6?

I updated my angular 5.2.10 project to angular 6.
I did step by step https://update.angular.io/, everything is OK unless Observable.from
In a service I used Observable.from(this.user) as following:

import { Observable } from 'rxjs/Observable';
...
Observable.from(this.users)// this.users is an array

It was OK, but in angular 6 the following error occurred

Property 'from' does not exist on type 'typeof Observable'

I changed it as follows

import { Observable, from } from 'rxjs';

But no change and error occurred again!

like image 389
Mohammad Dayyan Avatar asked May 05 '18 06:05

Mohammad Dayyan


1 Answers

This is changed from previous rxjs versions to rxjs6. (RxJS v5.x to v6 Update Guide)

Before rxjs 6

import { Observable } from "rxjs";

let numbers = [1, 5, 10];
let source = Observable.from(numbers);

With rxjs 6

import { from, Observable } from "rxjs";

let numbers = [1, 5, 10];
let source = from(numbers);
like image 128
Nipuna Avatar answered Oct 07 '22 01:10

Nipuna