Reputation: 113
I have students.component.html
<div *ngfor=“let student of students”
<p> {{ student.phoneNum }} </p>
displays: +12345678980 students object is coming from students.component.ts i want to display it as (234) 567-8980
how can i format it inside {{ }} ? can i use {{ formatNum(student.phoneNum) }} ? please suggest the best way to perform this.
Upvotes: 1
Views: 756
Reputation: 1559
Try use pipe, see Angular2 {pipes} - How to format a phone number?
Also you can handle it by call function As below:
<p [innerHtml]=formatNum(student.phoneNum)></p>
Upvotes: 2