【问题标题】:Display two lines in a row连续显示两行
【发布时间】:2016-09-20 14:19:16
【问题描述】:

我希望控制器中的值显示在同一列的两行中。

{{ngapp}}.controller("Controller", function($scope, $http, $modalInstance){
    $scope.selected=[];
    $scope.items=[  
        { 
            value:'Impact to Safety, regulatory compliance environment', 
            key:10, 
            color:'red'
        },
        {
            value:'Reliability Impact', 
            key:9, 
            color:'brown'
        }
    ]
});

html 中的代码:

<div class="well form-group" >
    <table class="table" cellspacing="1">
        <tr>
            <th>Rank</th>
            <th>Criteria: Type of loss incurred</th>
        </tr>
        <tr ng-repeat="item in items" onclick="selected.item= item" ng-click="sel(item)">
            <td ng-style="{ 'background-color': item.color }">{{item.key}}</td>
            <td> {{item.value}} </td>
        </tr>
    </table>

    //<label>{{selected.item}}</label>
    {% endverbatim %}
</div>

我希望将值:“对安全的影响”显示在一行中。并且“监管合规环境”在同一列和同一键的新行中。有人可以帮忙吗?谢谢。我是新来的。

其他部分的代码,参考这个问题,

Display value in a button by linking two modals

【问题讨论】:

  • 你能添加你的html吗?
  • 问题中添加了Html。

标签: html angularjs


【解决方案1】:

您可以使用https://www.npmjs.com/package/angularjs-filters 来执行此操作。

将“,”替换为“&lt;br /&gt;”,它应该出现在下一行。

{{item.value |  string.replace : ',': '<br />'}}  

【讨论】:

  • 很抱歉这不起作用! string.replace 也适用于 ',' 吗?
猜你喜欢
  • 2015-11-22
  • 2014-05-08
  • 2020-12-09
  • 1970-01-01
  • 2018-06-07
  • 2021-10-03
  • 2017-06-22
  • 2014-11-19
  • 2016-05-16
相关资源
最近更新 更多