Text
splitLines
Render pasted multiline content as readonly input rows.
Use it in your component
Standalone component
import { Component } from '@angular/core';
import { JsonPipe } from '@angular/common';
import { SplitLinesPipe } from 'extra-pipe';
@Component({
standalone: true,
imports: [SplitLinesPipe, JsonPipe],
template: `{{ "one\r\ntwo\n" | splitLines | json }}`,
})
export class ExampleComponent {
}
Template
{{ "one\r\ntwo\n" | splitLines | json }}
Try it live.
The output below runs the packed library. Edit data, not code.
Use double quotes for text, or a number, array, object or null.
No parameters: use []. Locale is controlled separately.
This pipe has no locale override.
Live template data
readonly value = "one\r\ntwo\n";
{{ value | splitLines | json }}
Rendered output
[
"one",
"two",
""
]