When I will try to display some data in a tags then it will not display properly, I getting some special character. I have put the data using [innreHTML] but it did not work.
<div [innerHTML]="{{latestnews.content_english}}"></div>
I am getting output:
“<p><strong>All donations towards the Prime Minister’s National Relief Fund (PMNRF) are notified for 100% deduction from taxable income under section 80G of the Income Tax Act, 1961</strong></p>”
You can define a function here, follow example code and apply it in your code.
<div [innerHTML]="html_entity(latestnews.content_english)"></div>
Open your page.ts file paste this below code:
html_entity(val){ var entities = [ ['amp', '&'], ['apos', '''], ['#x27', '''], ['#x2F', '/'], ['#39', '''], ['#47', '/'], ['lt', '<'], ['gt', '>'], ['nbsp', ' '], ['quot', '"'] ]; for (var i = 0, max = entities.length; i < max; ++i) val = val.replace(new RegExp('&'+entities[i][0]+';', 'g'), entities[i][1]); return val; }
Now it work properly.
Question and answer is powered by AnsPress.io