【问题标题】:The result is incorrect html element is get json in ionic 2结果是不正确的 html 元素是在 ionic 2 中获取 json
【发布时间】:2017-08-18 06:25:42
【问题描述】:

我在 ionic 中使用了 get json。

$http.get($scope.webServiceUrl+"example.php")
  .then(function(response){
    $rootScope.lists = response.data;
  });

我用php写了webservice

echo json_encode($data,JSON_HEX_TAG);

返回json数据并打印页面

text: "<h1>enes</h1>"

Json[{"id":"0","text":"&lt;h1&gt;enes&lt;/h1&gt;"}]

jsonviewer Image

打印到页面时的结果

enter image description here

不接受是 html 元素。我该如何解决?

【问题讨论】:

    标签: html json ionic-framework element


    【解决方案1】:

    如果您确定它是安全的并且可以呈现为未编码的 HTML,我认为您必须使用 ng-bind-html 指令。

    <div ng-controller="ExampleController">
     <p ng-bind-html="myHTML"></p>
    </div>
    

    【讨论】:

      猜你喜欢
      • 2018-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-13
      • 1970-01-01
      • 1970-01-01
      • 2018-03-24
      相关资源
      最近更新 更多