Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ng2-nested-search

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng2-nested-search

A simple custom pipe for filtering arrays in your angular(2+) projects and get the count of filtered items.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-80%
Maintainers
1
Weekly downloads
 
Created
Source

A simple custom pipe for filtering arrays in your Angular 2 projects (works with Angular 4 and Angular 5 too) and get the count of filtered items. It supports nested search and you may search the array of items on specific properties.

Screen Recording 2021-09-06 at 12 39 44 PM

Screen Recording 2021-09-06 at 12 36 50 PM

How to use

import FilterPipeModule to your module (here I'm lazy loading)

import { NgModule } from '@angular/core';
import { ViewCharacters } from './view-characters';
import { FilterPipeModule } from 'ng2-nested-search';

@NgModule({
  declarations: [
    ViewCharacters
  ],
  imports: [
    FilterPipeModule
  ],
})
export class ViewCharactersModule {}

initialize the searchText and filterMetadata in your page.ts as follows

searchText : string = "";
filterMetadata = { count: 0 };

characters = [
    {
        name : "Daenerys",
        family : "Targaryen",
        gender : "Female"
    },
    {
        name : "Jaime",
        family : "Lannister",
        gender : "Male"
    },
    {
        name : "Sansa",
        family : "Stark",
        gender : "Female"
    },
    {
        name : "Arya",
        family : "Stark",
        gender : "Female"
    },
    {
        name : "Theon",
        family : "Greyjoy",
        gender : "Male"
    }
]

add the ng2-nested-search component in your page.html as follows (only filtering on name and family in the example)

<input [(ngModel)]="searchText"/>

<div *ngFor="let character of characters | ngxSearchFilter: { 'name' : searchText, 'family' : searchText} : filterMetadata">

For enabling nested search, set isNestedSearch to true (by default it is false) in the filterMetadata as shown below

    searchName : string = "";
    searchFamily : string = "";
    filterMetadata = { count: 0, isNestedSearch : true };

in HTML

<input [(ngModel)]="searchName"/>
<input [(ngModel)]="searchFamily"/>

<div *ngFor="let character of characters | ngxSearchFilter: { 'name' : searchName, 'family' : searchFamily} : filterMetadata">

You can display the filtered elements count as follows

<div>
    <span>Total items filtered : </span>
    <span [innerHTML]="filterMetadata.count"></span>
</div>

Contact

gmail : melwin.vincent.90@gmail.com

Keywords

FAQs

Package last updated on 26 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc