Remove Duplicate values after *ngFor

Hi all,
This is my scenario,i want remove duplicate values from ion-options.

<ion-select [(ngModel)]="deliveryDate" placeholder="Date" item-start>
			<ion-label>Choose Date</ion-label>
			<ion-option  *ngFor="let order of pending_orders " value="{{order?.delivery_date}}">{{order?.delivery_date}}</ion-option>

Thanks in advance :wink:


is there a necessary reason why you want do that in the template?
Imho, keep your template as dumb as possible and use in template an array that only keeps need values.

Best regards, anna.liebt

1 Like

Thanks for the reply,i want to remove the duplicate values from json array
i think i do it in template is becase

{deliverydate:"19 monday"},
{deliverydate:"19 monday"}

I want to avoid the duplication of deliverydate in ion options,19 monday needs to show once.
can you help me on this?


little bit symplified, but something like that.

Best regards, anna-liebt

Thanks again,But my API response is not just an array,Json array of objects and delivery date is one of my key,Any way let me try this

Thats not working .Still the value is duplicated.I passed a json array of object to removeDuplicates function.I thinks this works only in case of array operation.Will not incase of array of objects.

    let unique_array = []
    for(let i = 0;i < arr.length; i++){
        if(unique_array.indexOf(arr[i]) == -1){
    return unique_array

Why you complicate your life ?
Try to use lodash library there is a function called : uniqBy to remove duplicate values

Anyway thaks for the reply.Can i remove the duplicate value from json array of objects?
Could you please make an example?

Yes you can. please search " lodash uniqBy " there is an example in the doc its very easy.

Okey Thanks @yajuve
Let me try that.