Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!