i am working with an angular application in version 10. Below requirement to learn observables with hardcoded json objects with no http calls. For example i have a interface
export interface cities {
cityId: number;
cityName: string;
}
Below is the code where i declare an observable
cities$: Observable<city[]>;
in the Oninit Method i create objects like this
ngOnInit() : void {
const cityData = [
{
cityId: 1,
cityName: 'Bangalore'
},
{
cityId: 2,
cityName: 'chennai'
}
];
// here i want to get the values in the observables. how can i do it
this.cities$ = ...
}
below is the html code
<ul>
<li *ngFor='let city of cities$ | async'>
<span [innerHTML] = 'city.cityName'>
</li>
</ul>