我在VISUAL studio code 裏是沒有出現error,但是當我執行程式,它就出現
ERROR Error: Uncaught (in promise): TypeError: Cannot read property ‘asObservable’ of undefined
core.js:6241
我的service code 如下:
import { Injectable } from ‘@angular/core’;
import {BehaviorSubject, ReplaySubject} from ‘rxjs’;
@Injectable({
providedIn: ‘root’
})
export class LibraryserivceService {
private bookrow: BehaviorSubject;
currentrow = this.bookrow.asObservable();
constructor() { }
addbookrow(row: any)
{
this.bookrow.next(row);
console.log(row);
}
}
thank you very much.