简体   繁体   中英

Can i use function inside curly braces in angular?

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM