Angularjs Pass Multiple Parameters to Pipe

Today, We want to share with you Angularjs Pass Multiple Parameters to Pipe.In this post we will show you angular pass multiple parameters to pipe, hear for how to pass multiple parameters to pipe in angular we will give you demo and example for implement.In this post, we will learn about pass multiple values to pipe angular with an example.

Angularjs Pass Multiple Parameters to Pipe

There are the Following The simple About pass multiple parameters to pipe angular 9 Full Information With Example and source code.

As I will cover this Post with live Working example to develop pass multiple parameters to pipe angular, so the how to pass multiple parameters to pipe in angular 6 is used for this example is following below.

Read Also:  Angular Pipes List Example Tutorial

How to Pass Multiple Parameters to Pipe in Angular?

Angular is a platform for building mobile & desktop web Based user friendly and light weight applications.Angular,It’s TypeScript-based open-source Angularjs web application framework.

Solution:

{{ member.desc | descPipe: 'arg1' : 'arg2' : 'arg3'  }}

transform(desc: any, id: any, name: any, blogspot: any): any {
    return desc + ': ' + 'Personal ID is ' + id + '. Personal Name is ' + name + '. Personal Website is ' + blogspot + '.';
}

How to implement Pipes / Filters in Angular 8 with multiple parameters to filter an array?

angularjs pass multiple parameters to pipe

src/app/desc-pipe.pipe.ts

import { Pipe, PipeTransform } from '@angular/core';
    
@Pipe({
  name: 'descPipe'
})
export class DescPipePipe implements PipeTransform {
     
  transform(desc: any, id: any, name: any, blogspot: any): any {
  
    return desc + ': ' + 'Personal ID is ' + id + '. Personal Name is ' + name + '. Personal Website is ' + blogspot + '.';
  
  }
     
}

Import Pipe: src/app/app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
  
import { AppComponent } from './app.component';
import { DescPipePipe } from './desc-pipe.pipe';
  
@NgModule({
  imports:      [ BrowserModule, FormsModule  ],
  declarations: [ AppComponent, DescPipePipe ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

Update Component: src/app/app.component.ts

import { Component } from '@angular/core';
  
@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  name = 'Angular';
  
  members = [
    {
      id: 1,
      name: 'Hardik Savani',
      gender: 'Male',
      blogspot: 'Pakainfo.com',
      desc: 'Personal Info: ',
    },
    {
      id: 2,
      name: 'Roshani Vala',
      gender: 'Female',
      blogspot: 'infinityknow.com',
      desc: 'Personal Info: ',
    },
    {
      id: 3,
      name: 'Sanajay Sagpariya',
      gender: 'Male',
      blogspot: 'angular.io',
      desc: 'Personal Info: ',
    }
  ]
}

Use Pipe in HTML

src/app/app.component.html

<h1>How to Pass Multiple Parameters to Pipe in Angular - Pakainfo.com</h1>
    
<table border="1">
  <tr>
    <th>ID</th>
    <th>Member Info</th>
    <th>Blogspot</th>
    <th>Desc</th>
  </tr>
  <tr *ngFor="let member of members">
    <td>{{ member.id }}</td>
    <td>{{ member.name }}</td>
    <td>{{ member.blogspot }}</td>
    <td>{{ member.desc | descPipe: member.id : member.name : member.blogspot  }}</td>
  </tr>
</table>

Web Programming Tutorials Example with Demo

Read :

Read Also:  Top 5 Best php PDF Generation libraries

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about angular pipe optional arguments.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

Your email address will not be published. Required fields are marked *