import { Injectable } from '@angular/core';
import { Book } from './book';
import { Observable } from 'rxjs';
import { of } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class BookService {
constructor() { }
BOOKS : Book[]=[
{"id": 1, "name" : "JavaScript", "price" :"100", "description": "javscript"},
{"id": 2, "name" : "Angualr", "price" :"200", "description": "Angualr"},
{"id": 3, "name" : "Sql server", "price" :"3000", "description": "Sql server"},
{"id": 4, "name" : "Typescript", "price" :"5000", "description": "Typescript"},
]
getBooks(): Observable<Book[]>{
return Observable.of(this.BOOKS);
}
}
类型为“可观察的类型”的属性不存在“ of”。ts(2339)
我尝试了两个import语句,仍然给出了
import { of } from 'rxjs';
import 'rxjs/add/observable/of';
类型为'typeof Observable'的属性'of'不存在.ts(2339) 属性“ of”在类型“ typeof Observable”上不存在。ts(2339) 属性“ of”在类型“ typeof Observable”上不存在。ts(2339)