I am trying to figure out why I keep receiving the error message:
"Uncaught (in promise): TypeError: this.dealership is undefined"
when working with the authentication.service.ts file.
export class AuthenticationService {
private currentUserSubject: BehaviorSubject<UserModel>;
public currentUser: Observable<UserModel>;
constructor(private http: HttpClient) {
this.currentUserSubject = new BehaviorSubject<UserModel>(
JSON.parse(localStorage.getItem('authenticatedUser'))
);
this.currentUser = this.currentUserSubject.asObservable();
}
public get currentUserValue(): UserModel {
return this.currentUserSubject.value;
}
login(username: string, password: string) {
// Code for login function
}
In the DealerSiteComponent,
export class DealerSiteComponent {
// Code for DealerSiteComponent
}
I admit that I struggle with understanding Observables. How can I improve my knowledge in this area?
Thank you.