In my earlier post, I had discussed about maintaining multi-line text format in AngularJS view. In this post, I'll share how to achieve the same in Angular. What I have described in this post is tested in Angular 7.
To provide a context, let us say you are creating a page using Angular and rendering data from a SharePoint list/library. One of the columns is multiple lines of text with rich text enabled. The objective is to display the rich text as it is.
In AngularJS, we created a custom filter and used that filter in the HTML element.
In Angular, it is pretty easy. Angular already provides [innerHTML] property to handle such cases. Let's look at an example.
Here, "description" is a property in Angular component which holds the value of a multi-line text column.
If you are thinking if it is safe to use this, check the Angular documentation on security (yes, it is safe!)
To provide a context, let us say you are creating a page using Angular and rendering data from a SharePoint list/library. One of the columns is multiple lines of text with rich text enabled. The objective is to display the rich text as it is.
In AngularJS, we created a custom filter and used that filter in the HTML element.
In Angular, it is pretty easy. Angular already provides [innerHTML] property to handle such cases. Let's look at an example.
<p [innerHTML]="description"></p>
Here, "description" is a property in Angular component which holds the value of a multi-line text column.
If you are thinking if it is safe to use this, check the Angular documentation on security (yes, it is safe!)
Comments
Post a Comment