DEVHIDE
  • Home (current)
  • About
  • Contact
  • Cookie
  • Home (current)
  • About
  • Contact
  • Cookie
  • Disclaimer
  • Privacy
  • TOS
Login Or Sign up

Angular 9 Async pipe and search filter

1.5k Views Asked by Sunil Rawat At 14 August 2020 at 08:59 2025-12-01T00:20:12.823000
<input 
  type="text" 
  class="form-control" 
  id="search-text" 
  [(ngModel)]="searchText" 
  placeholder="Enter text to search"
  autofocus
>
<div class="dropdown-divider m-0"></div>

<ul class="list-group list-group-flush" *ngIf="users$ | async as users">
  <li class="list-group-item d-flex justify-content-between align-items-center card-body__headings">
    <span class="float-left">{{(users$| async)?.length}} users</span>
  </li>

  <li 
    class="list-group-item d-flex justify-content-between align-items-center" 
    routerLink="userdetail"
    *ngFor="let user of users | search: searchText "
  >
    +++{{user | json}}
    <span class="float-left w-100">
              <p class="user-initial">{{user.NAME_INITIALS }}</p>
              <em class="list-group-item__detail">
                {{user.FIRSTNAME}} {{user.LASTNAME}}
                <br/>
                <em class="list-group-item__email">{{user.EMAIL}}</em>
              </em>
            </span>

    <span class="badge">
      <ish-icon icon="user.remove" cssClass="action-icon"></ish-icon>
     </span>
  </li>
</ul>

where search is the pipe for filtering the data. When i inspected in filter it is returning me the proper search result but it's not rendering on UI. Means the search result is not rendering.

angular rxjs6 angular-filters angular-pipe
Original Q&A
1

There are 1 best solutions below

0
Sunil Rawat Sunil Rawat On 14 August 2020 at 10:36 BEST ANSWER

got the answer after searching so long.

HTML

<ul class="list-group list-group-flush" *ngIf="users$ | async as users">
      <li class="list-group-item d-flex justify-content-between align-items-center card-body__headings">
        <span class="float-left">{{(users$| async)?.length}} users</span>
      </li>

      <li class="list-group-item d-flex justify-content-between align-items-center" routerLink="userdetail"
        *ngFor="let user of users | search: 'FIRSTNAME,LASTNAME,EMAIL': searchText ">

        <span class="float-left w-100">
          <p class="user-initial">{{user.NAME_INITIALS }}</p>

          <em class="list-group-item__detail">
            {{user.FIRSTNAME}} {{user.LASTNAME}}<br />
            <em class="list-group-item__email">{{user.EMAIL}}</em>
          </em>
        </span>

        <span class="badge">
          <ish-icon icon="user.remove" cssClass="action-icon"></ish-icon>
        </span>
      </li>
    </ul>

Search pipe

public transform(value, keys: string, term: string) {

if (!term) return value;
return (value || []).filter(item => keys.split(',').some(key => item.hasOwnProperty(key) && new RegExp(term, 'gi').test(item[key])));

}

Related Questions in ANGULAR

  • Firebase link existing user to anonymous account?
  • It doesnt always show all the books on my homepage
  • Google adsense ads.txt status cannot be not found
  • When I navigate to the URL'http://localhost:4200/', it redirects me back
  • Ionic Angular Standalone ion-icon are not showing at all
  • How to make Angular understand that view child is of a specific type, not a general ElementRef?
  • vscode, debug angular, first time, doesn't debug, 2nd time stops at main.js then it's ok
  • How to perform CRUD operations on a static JSON array in Angular? (without API)
  • Ngrx props<>() method in createAction()
  • How to animate rotation of an image inside input control?
  • Detecting click inside and outside of the listening component in Angular
  • Angular - type guard not narrowing types
  • In node_modules file i am getting Angular genric error while using fontawesome in angular12
  • Angular 16 sending null values to API
  • GoogleCloud Error: Not Found The requested URL was not found on this server

Related Questions in RXJS6

  • Why I am unable to emit reducer function from an effect?
  • Angular combine multiple router events
  • Angular RxJS forkJoin switchMap return observable of boolean
  • Angular Rxjs Manage Nested Subscriptions
  • I have a problem with this in the new version | seconde: number; const counter = Observable.interval(1000);
  • Timeout stops stream rxjs Angular
  • Angular service data caching with RxJS
  • Display loader only when api call will be longer then 1 sec
  • What version of rxjs is compatible with both Angular 16 and ngx-chips 3.0.0?
  • rxjs 5 -> 6 migration: connect operator missing
  • Angular 16 Material Table dataSource doesn't accept declarative RxJS Object[]
  • How do I resubmit an action stream observable after a failed attempt in Angular/RxJS?
  • fromFetch operator does not reset cache on unsubscribe
  • RxJS fromevent doesn't seems to work with keyup event
  • How can I get RXJS throttleTime to enable both leading and trailing while preventing requests in quick succession

Related Questions in ANGULAR-FILTERS

  • How to use dependent filters on AG-Grid
  • Angular Dropdown Filter - Button
  • Angular generic table multiple columns filtering custom filterPredicate
  • Disable few filters from default kendo grid filters angular
  • my filter does not work on the mat-table data table Angular Typescript
  • How to filter through a FormArray using Pipe in Angular to search for specific value?
  • Dependency injection in custom filters
  • Remove duplicates by comparing two arrays
  • angularjs NgTable ng-repeat groupby with show/hide
  • Angular Material - Custom Column filter and Default filter not working together
  • I want to hide the parent div if child div is empty as Filter results empty
  • Multiple filters in angular
  • How to use filter method to filter array based on array field values in angular
  • AngularJS filter | orderBy with custom order
  • angular search filter with boolean checkboxes

Related Questions in ANGULAR-PIPE

  • DecimalPipe in angular cut the string if its more than 10 digits
  • Display issue with an observable in Angular 17: the page loads indefinitely
  • Does async pipe trigger onPush change detection in angular?
  • How to consume Custom pipe defined in a angular library?
  • Angular pipe to reduce objects based on the array of object keys
  • How to add an angular pipe in a service in Angular 17?
  • How to use async pipe with arrays in new Angular 17?
  • Angular Pipe chaining on a element does not work
  • On angluar, how to use pipe on parameters used in translation
  • How to use common module api into a service in standalone approach
  • Impure Pipe VS Event Subscription in Pipe
  • Angular smart pipe
  • Add currency symbol at right or left
  • Custom pipe not found error in microfrontend remote app
  • Pipe on init not working on reactive form Angular 14

Trending Questions

  • UIImageView Frame Doesn't Reflect Constraints
  • Is it possible to use adb commands to click on a view by finding its ID?
  • How to create a new web character symbol recognizable by html/javascript?
  • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
  • Heap Gives Page Fault
  • Connect ffmpeg to Visual Studio 2008
  • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
  • How to avoid default initialization of objects in std::vector?
  • second argument of the command line arguments in a format other than char** argv or char* argv[]
  • How to improve efficiency of algorithm which generates next lexicographic permutation?
  • Navigating to the another actvity app getting crash in android
  • How to read the particular message format in android and store in sqlite database?
  • Resetting inventory status after order is cancelled
  • Efficiently compute powers of X in SSE/AVX
  • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

Popular # Hahtags

javascript python java c# php android html jquery c++ css ios sql mysql r reactjs node.js arrays c asp.net json

Popular Questions

  • How do I undo the most recent local commits in Git?
  • How can I remove a specific item from an array in JavaScript?
  • How do I delete a Git branch locally and remotely?
  • Find all files containing a specific text (string) on Linux?
  • How do I revert a Git repository to a previous commit?
  • How do I create an HTML button that acts like a link?
  • How do I check out a remote Git branch?
  • How do I force "git pull" to overwrite local files?
  • How do I list all files of a directory?
  • How to check whether a string contains a substring in JavaScript?
  • How do I redirect to another webpage?
  • How can I iterate over rows in a Pandas DataFrame?
  • How do I convert a String to an int in Java?
  • Does Python have a string 'contains' substring method?
  • How do I check if a string contains a specific word?
.

Copyright © 2021 Jogjafile Inc.

  • Disclaimer
  • Privacy
  • TOS
  • Homegardensmart
  • Math
  • Aftereffectstemplates