I'm using a service to share data between two unrelated controllers as mentioned in this article
This is the service which i use to share the data
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class AppService {
tempfile = "temp";
file: BehaviorSubject<string>;
count: BehaviorSubject<number>;
constructor() {
this.file = new BehaviorSubject(this.tempfile);
}
}
I injected this service to my component,but when i try to get the value from the service
this.appsevice.file.subscribe(c => {
this.file = c;
});
i keep getting the following error
this.appsevice.file.subscribe is not a function