После изменения типа переменной на Observable в другом месте моего кода появляются сообщения об ошибках, которые я не могу обработать.
Observable в authService Я создал таким образом:
private activeBusinessCase = new BehaviorSubject<string>(null);
public activeBusinessCase$ = this.activeBusinessCase.asObservable();
В той же службе я получаю сообщение об ошибке ..
Свойство 'toLowerCase' не существует для типа 'BehaviorSubject'
.. для этой строки кода:
this.router.navigate ([Constants.routing.explorer + this.activeBusinessCase.toLowerCase ()]);
В моем home.component.ts я получаю следующее сообщение об ошибке ..
Свойство 'activeBusinessCase' является частным и доступно только в классе 'UserAuthService'.
.. для следующих строк кода:
ngOnInit () {
this.router.navigate ([Constants.routing.explorer + this.authService.activeBusinessCase.toLowerCase ()]);
}
Но самое важноесообщение об ошибке в моем httpService , в котором больше ничего не работает:
getResource (key: string, lang: string): Observable <any> {
const headers = new HttpHeaders ({'Accept': 'text / html'});
return this.httpClient.get ('/ resources /' + key,
{
headers: headers,
responseType: 'text',
params: new HttpParams ()
.set ('businessCase', this.authService.activeBusinessCase? this.authService.activeBusinessCase:
environment.default_business_case)
.set ('long', long)
}) Pipe. (
catchError (() => {
return this.translateService.get ('Not-available'). pipe (
map (res => '<h4 style = "text-align: center">' + res + '</ h4>'));
})
);
}
getResources (long: string): Observable <Resource []> {
return this.httpClient.get <any> ('/ resources',
{
params: new HttpParams ()
.set ('long', long)
.set ('businessCase', this.authService.activeBusinessCase? this.authService.activeBusinessCase:
environment.default_business_case)
});
}
Вот сообщение об ошибке в консоли sais:
Ошибка TS2341: свойство«activeBusinessCase» является частным и доступен только в классе «UserAuthService».
Я все еще новичок в Angular и благодарен за любую подробную помощь.