I'm trying to bind the location variable in the component to another variable in the store via selector with ngrx v13 in angular, but when I put the variable with the property in the HTML I get an error:
error message: Property 'name' does not exist on type 'Observable'
that is my code:
app.selector.ts
import { createSelector } from "@ngrx/store";
export const CurrentLocationSelector=(state:AppState) => state.currentLocation;
export const getCurrentLocation = createSelector(
CurrentLocationSelector,
(currentLocation: any) => {
return [...new Set(currentLocation)];
}
);
that is my AppState:
interface AppState{
darktheme:boolean;
temperatureUnit:string;
currentLocation:any; // object with the current location
locationAutoComplete:any[]; // array that contains the result from the autocomplete
locationCurrentWeather:CurrentItem | null;
Forecast5Days:ForecastItem[];
Favorites:FavoriteItem[];
loading:boolean;
getData:boolean;
}
in my component i wrote: current-weather.component.html
<div class="left">
<span class="locationName">{{location$.name}}</span>
<span class="date">{{currentFullDate}}</span>
<div class="weatherDescription">
<img [src]="imageCurrentWeather" class="weatherIcon">
<div class="weatherText">{{CurrentWeather.WeatherText}}</div>
</div>
<h1 [innerHTML]="CurrentWeather.Temperature + ' ' + currentUnit"></h1>
</div>
in my current-weather.component.ts I wrote
location$ = this.store.pipe(select(CurrentLocationSelector))