Angular Hex pipe
The following Angular pipe formats the input as Hex:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'hex',
standalone: true,
})
export class HexPipe implements PipeTransform {
transform(value: number): string {
if (isNaN(value)) {
return '';
}
return value.toString(16).toUpperCase();
}
}
Example usage
{{ 255 | hex }} <!-- FF -->