我正在使用Angular JS進行簡單的網絡應用程序。將JSON字符串格式化爲段落
我有一個包含多個段落的JSON對象。因此我需要將這些段落分成兩行。我做了一些研究,並且發現了類似問題的一些答案,但是因爲它們沒有放在上下文中,所以我不瞭解它們。我嘗試着去查看JSON是否有內置的東西來強制換行,因爲這樣做,但我沒有找到。
非常感謝幫助!
HTML瓦特/角JS
<div class="bio">
{{exhibits[whichItem].bio}}
</div>
JSON
[
{
"name":"Name goes here",
"bio":"First long block of text goes here then it needs a break <br /> and the second long block of text is here."
}
]
AngularJS - controllers.js
var exhibitListControllers = angular.module('exhibitListControllers', ['ngAnimate']);
exhibitListControllers.controller('ListController', ['$scope', '$http', function($scope, $http){
$http.get('js/data.json').success(function(data) {
$scope.exhibits = data;
$scope.exhibitOrder = 'name';
});
}]);
謝謝你一起發送!我試圖遵循這一點,雖然我認爲我理解它,但我正努力將其與當前的控制器合併。我將Angular JS - controllers.js添加到了我的問題中,以澄清當前的設置,並且找到了一些有關此答案的其他指導。 – user5854648
在$ scope.myHTML中引用了一個字符串,但是這個字符串是JSON文件中JSON對象的一部分。我不知道如何合併它。 – user5854648
我還沒有試過你的代碼,但我不認爲它可能很重要,它應該使用JSON或非JSON字符串。 –