2016-07-19 4 views
0

からHTMLを保存します改行。ここでangularjsが、これは私のhtmlでテキストエリア

を編集するとき、それは次のようになります。

enter image description here

そしてここでは、編集していないとき、それは次のようになります。

enter image description here

私はまだ編集の間ではなく切り替えることができます私は同じ結果を得るでしょう。

編集していないときに改行が表示されるようにするにはどうすればよいですか?

答えて

1

あなたはpreタグを使用して試すことができます:

<pre class='door-description' ng-bind-html="item.Description"></pre> 
0

ちょうどあなたの要素にこのスタイルを適用します。

white-space: pre; 
0

あなたは

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> 
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-sanitize.js"></script> 
<body> 

<div ng-app="myApp" ng-controller="myCtrl"> 

<textarea elastic class='door-description' ng-bind-html="myText " ng-model="myText "></textarea> 
</div> 

<script> 
var app = angular.module("myApp", ['ngSanitize']); 
app.controller("myCtrl", function($scope) { 
    $scope.myText = "My name is: <div><h1>John Doe</h1></div>"; 
}); 
</script> 

が、このことも、このように使用していただけます働くでしょう 。

それはのようなオブジェクト与える、

My name is: <div><h1>John Doe</h1></div> 
関連する問題