How do I remove whitespaces from a text string in my Angular application?
For example:
{{ someobject.name }}
The value of someobject.name is "name abc"
I want to achieve the result as "nameabc" (by removing all whitespaces).
I have already created a custom pipe and included it in the typescript file and module.
CUSTOM PIPE:
import { Pipe, PipeTransform } from "@angular/core";
@Pipe({ name: 'trim' })
export class TrimPipe implements PipeTransform {
transform(value: any) {
if (!value) {
return '';
}
return value.trim();
}
}
Using {{ someobject.name | trim }} still displays "name abc" instead of "nameabc".