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

ngx-mat-menu-filter

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-mat-menu-filter

Plug and play filter for your projects that use angular material.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

NgxMatMenuFilter

A plug and play filter for your projects that use angular material.

Dependencies

  • Angular
  • Angular material

Features

  • Different Types of Input Filters
  • Multiple Input Filters

Demo

Demo Application

Note

You need to have @angular/material installed in your project, as it is a Peer Dependency.

Example

mat-menu-filter example

Installation

After installing the above dependencies. Install ngx-mat-menu-filter via.

npm i ngx-mat-menu-filter

Once installed you need to import our main module in your application module:

import { NgxMatMenuFilterModule } from "ngx-mat-menu-filter";

@NgModule({
  declarations: [AppComponent, ...],
  imports: [NgxMatMenuFilterModule, ...],
  bootstrap: [AppComponent]
})
export class AppModule {
}

Usage

ngx-mat-menu-filter is designed to work with mat-menu, so you'll need to create a button that will trigger the menu filter. For example:

<button [matMenuTriggerFor]="filterMenu" #filterMenuTrigger="matMenuTrigger">
  <mat-icon fontSet="material-icons-outlined">filter_alt</mat-icon>
  Filter
</button>

<mat-menu #filterMenu="matMenu">
  <ngx-mat-menu-filter
    (click)="$event.stopPropagation()"
    (filterValues)="applyFilters($event)"
    [filters]="defaultFilters"
    [allFilters]="allFilters"
  >
  </ngx-mat-menu-filter>
</mat-menu>

You'll need to create the required properties and method in your ts file i.e: defaultFilters, allFilters and applyFilters Hence, a sample for these would be.


  defaultFilters = [
    { name: 'productName', type: 'field', placeholder: 'Product Name' },
    { name: 'userName', type: 'field', placeholder: 'User Name' },
  ]

  allFilters = [
    { name: 'productName', type: 'field', placeholder: 'Product Name' },
    { name: 'userName', type: 'field', placeholder: 'User Name' },
    { name: 'email', type: 'field', placeholder: 'Email' },
    { name: 'amount', type: 'field', placeholder: 'Amount' },
    { name: 'date', type: 'date', placeholder: 'Date' },
    { name: 'status', data$: of([{ name: 'Pending' }, { name: "Completed" }, { name: "Failed" }]), type: 'select', key: 'name', label: 'name', placeholder: 'Order Status' },
  ]

  applyFilters(filters: any) {
    //filters is an object that returns a key/value pair of your filters.
    console.log(filters)
  }

Keywords

FAQs

Package last updated on 27 Mar 2023

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