I see the filtered data on the screen, but the original data does not appear when I clear the input
**
Here I show _todayShare in the <a> tag as an item in order**
<span>Share</span>
<input
[(ngModel)]="sharedsearchText"
(keyup)="applyFilter(sharedsearchText)"
style="width: 50%; margin-top: 1px; margin-bottom: 1px;"
matInput
placeholder="Ara..."
/>
</div>
<div class="list" slim-scroll [slimScrollOptions]="{ height: 450 }">
<a
*ngFor="
let item of _todayShare | keyvalue : valueAscOrder;
let i = index
"
style="cursor: pointer"
class="transition"
(click)="showliveRss(item)"
>
_todayShare is a map as you understand and I made a copy of it below, but again it didn’t work.
_todayShare: Map<string, any> = new Map<string, any>();
ngOnInit() {
this._todayShare = new Map<string, any>();
....
applyFilter(value: string) {
const filterValue = value.trim().toLowerCase();
const filteredMap = new Map<string, any>();
const _todayShareBackup = new Map<string, any>(this._todayShare)
_todayShareBackup.forEach((item, key) => {
if (key.toLowerCase().includes(filterValue) ||
JSON.stringify(item).toLowerCase().includes(filterValue)) {
filteredMap.set(key, item);
}
});
this._todayShare = filteredMap
}
When I clear the input here, I want all of my data to come as follows
New contributor
Serkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.