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

192
Vistas
Angular js interpolation issue when string format

I am trying to format the string in the HTML. This is my html Sample

      <tr ng-repeat="dob in userId.dobs">
                <td align="center">{{$index + 1}}</td>
                <td>{{dob.dateType}}</td>
                <td>{{dob.birthDate}}</td>
                <td>{{dob.dateYear}}</td>
                <td>{{dob.fromYear}}</td>
                <td>{{dob.toYear}}</td>
            </tr>

Currently my {{dob.fromYear}}show like 1973/01/21. But I need to split this string and keep only the year. Its like below {{dob.fromYear}} show like 1973. I tried to do it using below technique

 <td>{{dob.fromYear.split('/')}}</td>

now my result like ["1973","01","21"] enter image description here

I need to display only the year. How i do it.?

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

0

You can try

dob.fromYear.split('/')[0]

But i think this could be problematic if the date is in another format. So better to use:

new Date(dob.fromYear).getFullYear()
about 4 years ago · Juan Pablo Isaza Denunciar

0

You should create a pipe. Pass the dob string to the pipe and inside the pipe you can do some text manipulation to get only the year.

const year = "1111/22/33".split("/").slice(0,1).join()
return year;

This code first splits the string. Then slice(0,1) picks the year part and .join() converts the [1111] into a string.

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