I have a JSON file generated via php:
$JsonObjItems = json_encode($arrObjItems, JSON_PRETTY_PRINT);
$objFile = new \File('test.json', true);
$objFile->write($JsonObjItems);
$objFile->close();
JSON:
[
{
"raw": {
"id": "2",
"pid": "0",
"sorting": "0",
"tstamp": "1433706234",
"Alias": "-2",
"Menu1": "Test (A,C,F)\nTest1, Gr\u00fcn",
"Menu2": "Test1",
"From": "1433714400",
"To": "1434060000",
"Published": "1"
},
"text": {
"Alias": "-2",
"Menu1": "Test (A,C,F)\nTest1, Gr\u00fcn",
"Menu2": "Test1",
"From": "08.06.2015",
"To": "12.06.2015",
"Published": "1"
},...
I'm parsing that within an angularjs/ionic app:
.controller('GetJson', function ($scope, $http) {
$http.get("test.json")
.success(function (data) {
$scope.all = data;
$scope.menu1 = data[0].text.Menu1;
});
})
And put it out here:
<ion-view view-title="test" ng-controller="GetJson">
<ion-content class="padding">
{{menu1}}
</ion-content>
</ion-view>
That generates this output:
Test (A,C,F)\nTest1, Gr\u00fcn
What I want is:
Test (A,C,F)
Test1,
Grün
How can I do that? Within the javascript json encode or within the php generating the json? I tried that stuff in the php but I didn't got it working:
$JsonObjItems = json_encode($arrObjItems, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
EDIT:
With the "$sce.trustAsHtml" Filter it works here: https://jsfiddle.net/uPw2U/163/ But not with expressions: https://jsfiddle.net/gstcppgt/3/
In both cases the \n line break is ignored, do I have to use nl2br() somehow? I tried it here: without the expressions it works: https://jsfiddle.net/uPw2U/170/
With expressions it doesn't: https://jsfiddle.net/gstcppgt/11/
Whats wrong with the {{ }} stuff?
<span ng-bind-html="html|html">not{{html | html}}