File

projects/angular/pipes/src/nl2br/nl2br.pipe.ts

Metadata

Methods

transform
transform(value?: string | null)
Parameters :
Name Type Optional
value string | null Yes
Returns : any
import {
    Pipe,
    PipeTransform,
} from '@angular/core';

@Pipe({ name: 'nl2br' })
export class UiNl2BrPipe implements PipeTransform {
    transform(value?: string | null) {
        return value ?
            value
                .replace(/\r\n/g, '<br/>')
                .replace(/\r/g, '<br/>')
                .replace(/\n/g, '<br/>')
            :
            null;
    }
}

results matching ""

    No results matching ""