1

Source code:

<tr ng-repeat="x in orderCsList">
  <td class="ctn"><input type="checkbox" ng-model="x.checked"></td>
  <td class="ctn">{{ x.wdate }}</td>
  <td class="text-left">{{ x.wid }}</td>
  <td class="text-left">{{ x.content }}</td>
  <td class="text-left">{{ x.suc_yn }}</td>
</tr>

I have a property(x.contents) that the value is TEST<br>TEST. How can I "parse" it to HTML?

Actual result:

TEST`<br>`TEST

Expected result:

TEST
TEST

1
  • Your question is very unclear. Commented Jul 6, 2016 at 2:36

2 Answers 2

1

Did you try:

<td class="text-left" ng-bind-html="x.content"></td>

See link: https://docs.angularjs.org/api/ng/directive/ngBindHtml

Make note that Sanitize required https://docs.angularjs.org/api/ngSanitize/service/$sanitize

Sign up to request clarification or add additional context in comments.

Comments

1

Use ngBindHtml directive.

Here's is a snippet working:

(function() {
 "use strict";
 angular.module('app', ['ngSanitize'])
   .controller('mainCtrl', function() {
     var vm = this;
     
     vm.parsed = 'TEST<br>TEST';
   });
})();
<!DOCTYPE html>
<html ng-app="app">

<head>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.7/angular.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-sanitize/1.5.7/angular-sanitize.min.js"></script>
</head>
<body ng-controller="mainCtrl as main">
  <strong>Before parse:</strong><br><span ng-bind="main.parsed"></span>
  <hr>
  <strong>After parse:</strong><br><span ng-bind-html="main.parsed"></span>
</body>
</html>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.