1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

How to wrap an object contains a metric unit e.g. length= 10 m with Angular signals?

Discussão em 'Angular' iniciado por Juergen Gross, Junho 28, 2025.

  1. What is the correct implementation for an object in the signal world of angular?

    A): all wrapped with signal as:
    length=signal ({
    nominalValue: signal(0),
    unit: signal ("mm") })

    or B): only the key: value wrapped with signals as:
    length= {
    nominalValue: signal(0),
    unit: signal ("mm") }

    or C) only the object itself wrapped with signal as:
    length=signal( {
    nominalValue: 0,
    unit: "mm" })

    By the html field and , I have to manipulate the objects key: values.
    The following example is without signals:

    <input [(ngModel)]='length.nominalValue'
    (keyup)=' keyup (length)'>


    Note: the triggered keyup() function will handle the changes by ...spread the object and at least invoke the related post calculations.

    <button (click)='unitSwitch(length)'>
    {{ length.unit }}</button>


    The same for the units, but manipulated by a button.

    Continue reading...

Compartilhe esta Página