How to render a hyperlink in a component template in Angular 6?

Vini

I have an Angular 6 application where a component is used to display a message on the page. Some of the messages contain hyperlinks embedded in them (in HTML markup). However, when the messages are displayed on the page, they are getting displayed in plain text (hyperlinks are not rendered, but the markup is displayed to the user instead).

You can visit Stackblitz @ https://stackblitz.com/edit/angular-jj5nms for a sample application that I created to explain the issue.

Expected message display:

Click here.

Actual message display:

Click <a href='http://www.google.com'>here</a>

Neil Stevens

If you want to render HTML a then you need to bind to the innerHTML property of an element, for example:

<p [innerHTML]=“message | async”></p>

Where message is your observable from the service.

Using handlebars to render message is just rendering plain text, binding to innerHTML and using the async will render your html content

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Angular - Render a template in a sibling component

From Dev

How can I render template with context in an Angular component?

From Dev

How to inject and render the component in template?

From Dev

Dynamic Template in Component Angular 6

From Dev

AG Grid / Angular 6 - trying to render a hyperlink with two columns

From Javascript

How to use es6 template literal as Angular Component Input

From Dev

Angular 6 - How to change a component's value in its template on a IF condition

From Dev

How to render Angular component as control

From Dev

How to render template inside of template with angular and django

From Dev

How to make Angular 2 render HTML template after a promise in the component is resolved?

From Dev

How to get inner html of Angular6 component and add it to component template?

From Dev

Insert a template to child component in angular 6

From Dev

Why does Angular 2 render app component template twice

From Dev

Angular 9: how to re-render component

From Dev

how to render a HTML template on button click in angular

From Dev

Angular 6 Waiting service response before render template

From Dev

Render view inside iframe in Angular 6 and continue to use template variables

From Dev

How to use directives when you have inline template in Angular 6 component?

From Dev

how can I transclude child component template into its parent in Angular 6+?

From Dev

Angular 6 how to show spinner on menu item or hyperlink click

From Dev

Template Url in component not working while Angular 1.5 to Angular 6 migration

From Dev

How to pass a component type to render to another component in Angular?

From Dev

How to render ng-template dynamically with Template Reference in Angular

From Dev

Vue - how can i render a script inside a component template?

From Dev

How to render multiple Component-type variables through a template

From Dev

how to fix Failed to mount component: template or render function not defined in vue

From Dev

How to render escaped html in Angular 6

From Dev

Render Component A in Component B Angular

From Dev

Render instance of a component in Angular?

Related Related

  1. 1

    Angular - Render a template in a sibling component

  2. 2

    How can I render template with context in an Angular component?

  3. 3

    How to inject and render the component in template?

  4. 4

    Dynamic Template in Component Angular 6

  5. 5

    AG Grid / Angular 6 - trying to render a hyperlink with two columns

  6. 6

    How to use es6 template literal as Angular Component Input

  7. 7

    Angular 6 - How to change a component's value in its template on a IF condition

  8. 8

    How to render Angular component as control

  9. 9

    How to render template inside of template with angular and django

  10. 10

    How to make Angular 2 render HTML template after a promise in the component is resolved?

  11. 11

    How to get inner html of Angular6 component and add it to component template?

  12. 12

    Insert a template to child component in angular 6

  13. 13

    Why does Angular 2 render app component template twice

  14. 14

    Angular 9: how to re-render component

  15. 15

    how to render a HTML template on button click in angular

  16. 16

    Angular 6 Waiting service response before render template

  17. 17

    Render view inside iframe in Angular 6 and continue to use template variables

  18. 18

    How to use directives when you have inline template in Angular 6 component?

  19. 19

    how can I transclude child component template into its parent in Angular 6+?

  20. 20

    Angular 6 how to show spinner on menu item or hyperlink click

  21. 21

    Template Url in component not working while Angular 1.5 to Angular 6 migration

  22. 22

    How to pass a component type to render to another component in Angular?

  23. 23

    How to render ng-template dynamically with Template Reference in Angular

  24. 24

    Vue - how can i render a script inside a component template?

  25. 25

    How to render multiple Component-type variables through a template

  26. 26

    how to fix Failed to mount component: template or render function not defined in vue

  27. 27

    How to render escaped html in Angular 6

  28. 28

    Render Component A in Component B Angular

  29. 29

    Render instance of a component in Angular?

HotTag

Archive