Activity Forums Salesforce® Discussions How to create custom Pipes in Angular 2 ?

  • Manpreet

    Member
    April 16, 2018 at 6:36 am

    Hi Amresh,

    You can create a custom pipe in a following manner :

    import {
    Pipe,
    PipeTransform
    } from '@angular/core';
    @Pipe({
    name: 'name of pipe used in markup'
    })
    export class NameofClass implements PipeTransform {
    transform(value: string, args: string[]): any {
    //Play with value and argument and return the result
    return value;
    }
    }

    // This is just a sample script. Paste your real code (javascript or HTML) here.

    if ('this_is' == /an_example/) {
    of_beautifier();
    } else {
    var a = b ? (c % d) : e[f];
    }

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos