【问题标题】:Insert a linebreak inside a ionic tag在离子标签内插入换行符
【发布时间】:2018-03-12 18:50:03
【问题描述】:

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

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

【问题讨论】:

    标签: html css angularjs ionic-framework tags


    【解决方案1】:

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

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

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

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

    在道具描述中:打字稿或javascript类中的字符串

    description:string = "<h1>My Header</h1> more text <br> and a break"
    

    【讨论】:

      【解决方案2】:

      我通过添加“item-text-wrap”类来添加换行符解决了我的问题。

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

      【讨论】:

        【解决方案3】:

        您需要使用ng-repeat 来实现如下所示:
        controller.js

        $scope.carven = carven;
        


        html

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

        【讨论】:

        • 你能给我提琴吗?如果您使用的是 ng-repeat,则无需添加换行符,它们会自动添加。
        • 我解决了我的问题...唯一要做的就是在类标签中添加“item-text-wrap”以添加换行符...无论如何,谢谢您的回答。
        • 很高兴知道@AlisonLopez
        猜你喜欢
        • 2012-12-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-24
        • 1970-01-01
        • 2013-09-07
        • 2020-11-06
        • 1970-01-01
        相关资源
        最近更新 更多