1

In my UI-grid column, I am trying to decode my string to HTML. I am working in UI-Grid Angular.

Here is my string "10-K ➤ EX-23.1" My output should be "10-K ➤ EX-23.1" but it shows string as it is. i have tried different solutions like using escape() and ['ngSanitize'] but these solutions didn't work at all in ui-grid.

Here is my Plunkr.

5
  • You only have to make it interpreted as HTML, no escape needed Commented Aug 19, 2015 at 7:34
  • @Hacketo can you give me the plunkr for that or any code help Commented Aug 19, 2015 at 7:39
  • 1
    looking at Hacketo answer, i think it may be useful to you: ng-bind-html="htmlString" Commented Aug 19, 2015 at 7:58
  • @deadManN Thanks it worked Commented Aug 19, 2015 at 8:04
  • Would you consider adding your Plunkr code to the question? As it stands the question does not contain enough information to investigate the problem - questions must be self-contained - and so it may be marked as off-topic. If you can fix it up, it would be much appreciated! Thanks. Commented Sep 1, 2015 at 21:06

3 Answers 3

2

My problem has been solved. you can achieve this thing by using ng-bind-html="htmlString". you only just need to change the celltemplate like this

cellTemplate: '<div class="ui-grid-cell-contents" ng-bind-html="COL_FIELD"></div>'
Sign up to request clarification or add additional context in comments.

Comments

0

i tried several things, as your model is on the go :D i mean is made using library, and is not build over your HTML, i change your model http://plnkr.co/edit/xMIwKxiNvkPLUPrRKt5o?p=preview

as you can find out i used this:

angular.element('<div />').html("10-K&nbsp;&#10148;&nbsp;EX-23.1").text()

here you go

next thing you need is to iterate through your model, and replace your incoming data with new data, which is parsed using that method

Comments

0

If we are trying to render the element which is coming from server as html-string in a row.entity way, follow the code below

header.cellTemplate = '<div ng-bind-html="row.entity.attribute"></div>';

or if we just want to render the html-string, instead of row.entity.attribute user the html-string as below

header.cellTemplate = '<div ng-bind-html="html-string"></div>';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.