Display/Edit a number in hex format

Discussão em 'Angular' iniciado por S.Kruse at WAGO, Fevereiro 11, 2025.

  1. Is there any built in way with Angular to use a Number type in my model as Hex Value in the HTML for Displaying and Editing? I have this type in my model:

    bitmask: number = 0;


    Which should now be presented as Hex Value in the frontend.

    <td *ngIf="!isEditing">{{parameter.bitmask}}</td>
    <td *ngIf="isEditing"><input type="text" [(ngModel)]="parameter.bitmask" maxlength="2" pattern="^(0-9a-fA-F)$" /></td>


    Any hint or help would be appriciated. I already tried it with a property in the model like this:

    get hexBitmask(): string {
    return this.bitmask.toString(16);
    }

    set hexBitmask(value: string) {
    this.bitmask = Number(value);
    }


    But it seems like I cannot use this in the binding on my frontend the same way as I did it with the bitmask field.

    Continue reading...

Compartilhe esta Página