Home > front end >  how to split text and add variable after first letter in angular
how to split text and add variable after first letter in angular

Time:02-24

here I have code,where i got error message as "Invalid phone number" but I need to add country which is variable after the first letter in text.How can i do it.

<p *ngIf="!result" > {{'REGISTER.ERROR'| translate}}</p>

CodePudding user response:

Do you want something like this to achieve: 'Invalid {country_name} phone number' ?

CodePudding user response:

I can see you are using ngxtranslate you should have mentioned that in the question for better under standing to get text in middle of variable dinamically something like "Invalid India phone number" then in translate json file you have to mention

"REGISTER":{
"ERROR":"Invalid {{value}} phone number"
}

and in html

<p *ngIf="!result" > {{'REGISTER.ERROR'| translate:param }}</p>

in ts

param={
value:"India"
}

i hope your issue got resolved happy coding

  • Related