Html 在ionic标记内插入换行符

Html 在ionic标记内插入换行符,html,css,angularjs,ionic-framework,tags,Html,Css,Angularjs,Ionic Framework,Tags,我正在使用ionic构建一个应用程序,我想在ionic标记中插入一个换行符(它将呈现一个字符串),这样它就可以在其容器中正确显示 <h2>{{caravan.model}}</h2> {{caravan.model} 您需要使用ng repeat进行如下所示的操作: 内部controller.js $scope.carven = carven; 和 在html中使用此选项 <div ng-repeat="data in carven"> <h2

我正在使用ionic构建一个应用程序,我想在ionic标记中插入一个换行符(它将呈现一个字符串),这样它就可以在其容器中正确显示

<h2>{{caravan.model}}</h2>
{{caravan.model}

您需要使用
ng repeat
进行如下所示的操作:
内部controller.js

$scope.carven = carven;

在html中使用此选项

<div ng-repeat="data in carven">
   <h2>{{data.model}}</h2>
 </div>

{{data.model}

使用Ionic2的一个解决方案是使用div的innerHtml

<div class="card-content" [innerHtml]="description"></div>

现在您可以使用任何HTML标记,如

<h1>, <br> or <p></p> etc..

等。。
在prop description中:typescript或javascript类中的字符串

description:string = "<h1>My Header</h1> more text <br> and a break"
description:string=“我的标题更多文本
和中断”
我通过添加类“item text wrap”来添加换行符,从而解决了我的问题

 <h2 class="item-text-wrap">{{caravan.model}}</h2>
{{caravan.model}

你能给我提琴吗。如果您使用的是ng repeat,则无需添加换行符,它们会自动添加。我解决了我的问题…唯一要做的就是在类标记中添加“项文本换行”,以便添加换行符…无论如何,感谢您的回答。很高兴认识@AlisonLopez