Angular-cli: br tag is not working data comming from json with br tag

Created on 7 Feb 2017  路  3Comments  路  Source: angular/angular-cli

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.

The log given by the failure.

Normally this include a stack trace and some more information.

Mention any other details that might be useful.


Thanks! We'll be in touch soon.

Most helpful comment

Hi @uyadav0001 , This issue is not related to the cli and would best be suited for: https://github.com/angular/angular

The issue you have is because you are most likely trying to load your data like:

var json = 'Hello </br>World';

Template:
<p>{{ json }}<p>

The correct way to do it would be:

<p [innerHTML]="json"></p>

This is frowned upon though due to the evident security flaws, you can read more about it here:
https://angular.io/docs/ts/latest/guide/security.html#!#xss

An alternative would be to bypass it with bypassSecurityTrustHtml

All 3 comments

Hi @uyadav0001 , This issue is not related to the cli and would best be suited for: https://github.com/angular/angular

The issue you have is because you are most likely trying to load your data like:

var json = 'Hello </br>World';

Template:
<p>{{ json }}<p>

The correct way to do it would be:

<p [innerHTML]="json"></p>

This is frowned upon though due to the evident security flaws, you can read more about it here:
https://angular.io/docs/ts/latest/guide/security.html#!#xss

An alternative would be to bypass it with bypassSecurityTrustHtml

Closed as answered.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gotschmarcel picture gotschmarcel  路  3Comments

brtnshrdr picture brtnshrdr  路  3Comments

hareeshav picture hareeshav  路  3Comments

MateenKadwaikar picture MateenKadwaikar  路  3Comments

sysmat picture sysmat  路  3Comments