Skip to content

Commit

Permalink
docs: Add compare function to relation custom input example
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed May 2, 2024
1 parent 2c9a53a commit d24cb34
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ import { GET_REVIEWS_FOR_PRODUCT } from '../product-reviews-list/product-reviews
<clr-icon shape="link"></clr-icon>
</a>
</div>
<select [formControl]="formControl">
<select [formControl]="formControl" [compareWith]="compareFn">
<option [ngValue]="null">Select a review...</option>
<option *ngFor="let item of reviews$ | async" [ngValue]="item">
<b>{{ item.summary }}</b>
Expand Down Expand Up @@ -247,6 +247,10 @@ export class RelationReviewInputComponent implements OnInit, FormInputComponent<
}),
);
}

compareFn(item1: { id: string } | null, item2: { id: string } | null) {
return item1 && item2 ? item1.id === item2.id : item1 === item2;
}
}
```

Expand Down

0 comments on commit d24cb34

Please sign in to comment.