【发布时间】:2017-05-05 10:25:16
【问题描述】:
我在 php 中创建了一个返回 unicode 数据的 api。
echo(json_encode($ary, JSON_UNESCAPED_UNICODE));
它只返回 ????? 但在 android 中它在接收后正确显示数据。
但离子不显示它。
可能是什么问题。
【问题讨论】:
标签: angularjs json ionic-framework
我在 php 中创建了一个返回 unicode 数据的 api。
echo(json_encode($ary, JSON_UNESCAPED_UNICODE));
它只返回 ????? 但在 android 中它在接收后正确显示数据。
但离子不显示它。
可能是什么问题。
【问题讨论】:
标签: angularjs json ionic-framework
您必须使用 $sce(严格上下文转义),请参阅下面的示例
var mOverview = angular.module('mOverview', []);
mOverview.controller('mOverviewController', function ($scope, $sce) {
$scope.mData = [
{
'name': '↓ '+'NASDAQ', // here the unicode is ↓ but the output is also ↓ which is supposed to be a down-arrow
'amount': '15,698.85',
'upDown': '+105.84'
}
];
});
mOverview.filter('unsafe', function($sce) {
return function(val) {
return $sce.trustAsHtml(val);
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="mOverview">
<div ng-controller="mOverviewController">
<table>
<tr>
<th></th>
<th></th>
<th></th>
</tr>
<tr ng-repeat="md in mData">
<td ng-bind-html="md.name | unsafe"></td>
<td>{{md.amount}}</td>
<td>{{md.upDown}}</td>
</tr>
</table>
</div>
【讨论】: