Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

251
Vistas
Which is a better way to access a large object's data members?

I have an object in my .ts file consisting of dozen of data members. Now, in order to render them in my html at different places for all different members, shall I reference it from the object directly -

.html

<p>{{obj.m1}}</p>
<p>{{obj.m2}}</p>

OR, I define each variable in .ts file differently - .ts

m1 : string = obj.m1;
m2 : string = obj.m2;

.html

<p>{{m1}}</p>
<p>{{m2}}</p>

I am not sure if it does make a difference.

Thank You!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It's perfectly fine to reference an object property (and its members) of a component from a template.

In order to do that, object property must be public (the default).

Good practice could be also to use Safe navigation operator (?) to avoid any null or undefined value in object member.

<p>The item name is: {{item?.name}}</p>

If item is null, the view still renders but the displayed value is blank; you see only "The item name is:" with nothing after it.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda