I have an application that uses the same service data on two different pages i.e Parent and Child.
On one of the pages, I am trying to filter the data to return a unique array based on a column using ngx-filter-pipe
module but the data still returns all values.
How do I return distinct values?
My code:
.module.ts-
import { NgModule } from '@angular/core';
import { NgPipesModule } from 'ngx-pipes';
@NgModule({
imports: [
NgPipesModule
]
})
...
.component.html-
<div padding=true>
<ul>
<li *ngFor="let group of musicList| unique: PLAYLIST_GROUP"></li>
</ul>
</div>
data from service-
[
{
"KEYS": 1,
"ARTIST": "Jamila Woods",
"TITLE": "LSD",
"ALBUM": "HEAVN",
"PLAYLIST_GROUP": "RnB/Soul",
"COUNT": 3
},
{
"KEYS": 2,
"ARTIST": "Travis Scott",
"TITLE": "SICKO MODE",
"ALBUM": "ASTROWORLD",
"PLAYLIST_GROUP": "Hip Hop",
"COUNT": 1
},
{
"KEYS": 3,
"ARTIST": "Rihanna",
"TITLE": "ANTI",
"ALBUM": "Yeah, I Said it",
"PLAYLIST_GROUP": "RnB/Soul",
"COUNT": 3
},
{
"KEYS": 4,
"ARTIST": "Summer Walker",
"TITLE": "Girls Need Love",
"ALBUM": "Last Day of Summer",
"PLAYLIST_GROUP": "RnB/Soul",
"COUNT": 3
}
]
According to the documentation for unique. The option requires another set of quotes.
Usage: array | unique: 'Property (Optional)'
<div padding=true>
<ul>
<li *ngFor="let group of musicList| unique: 'PLAYLIST_GROUP'"></li> <!--Quotes-->
</ul>
</div>