What is the correct way to iterate the array with map and filter? at present both expects the single value. but my Observable with array. please advice me the correct way.
here is my ts:
import { Component, OnInit } from '@angular/core';
import { Observable, of } from 'rxjs';
import { filter, map, tap} from 'rxjs/operators';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit {
name = 'Angular';
ranks:Observable<number[]>;
rankList$:Observable<number[]>;
constructor(){
this.ranks = of([1,2,3,4,5]);
}
ngOnInit(){
this.rankList$ = this.ranks.pipe(
filter(n => n % 2 !== 0), map((num:number[]) => num)
)
}
}
getting an error as:
The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.(2362)
(parameter) n: number[]