Skip to content

Commit

Permalink
example: store the filter result in a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
aVolpe committed Apr 10, 2018
1 parent 633695e commit 7524362
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ <h1>
</p>
</div>

<ng-container *ngIf="(items | filter:firstName) as data" >
<pre>{{ data | json }}</pre>
</ng-container>

</div>

2 comments on commit 7524362

@Virendra8Satva
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to get this filtered "data" into .ts file?

@aVolpe
Copy link
Owner Author

@aVolpe aVolpe commented on 7524362 Mar 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to get this filtered "data" into .ts file?

You can't get this data in your Component file, but you can manually call the filter funtion
in your class:

import {Ng2SearchPipe} from 'ng2-search-filter';

class MyComponent() {
     constructor() {
          const filtered = Ng2SearchPipe.filter([1,2,3], '1')
          console.log(filtered)' // [1]
     }

You can create issues in this project for further information: https://github.com/solodynamo/ng2-search-filter

Please sign in to comment.