user12296049
user12296049

Reputation:

How to use the operator of with observable?

So of course I googled a lot. For example this:

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

But what I try, it doesn't fix it.

So I have this:

import { Observable,} from "rxjs";
import { of } from 'rxjs/observable/of';



export class TranslateServiceStub{

    public get(key: any): any {
        Observable.of(key);
    }
}

But it keeps saying this:


Property 'of' does not exist on type 'typeof Observable'.ts(2339)

So what do I have to do to fix this?

Thank you

Upvotes: 1

Views: 159

Answers (2)

Nicolas
Nicolas

Reputation: 8670

If you are importing the function of from RxJS, why would you use it on observable ? just use it like that of(key). You don't have to call any object before that.

Upvotes: 0

Bilel-Zheni
Bilel-Zheni

Reputation: 1312

import of from 'rxjs' not 'rxjs/observable/of';

import { of} from "rxjs";

Upvotes: 1

Related Questions