2016-09-20 83 views
0

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

{{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' 
     } 
    ] 
}); 

代码:

<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

+0

你能添加你的html吗? –

+0

在问题中添加了Html。 –

回答

1

您可以使用https://www.npmjs.com/package/angularjs-filters做到这一点。

将','替换为'<br />',它应该出现在下一行。

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

对不起这个不行! string.replace是否也适用于','? –

+0

没有工作如何?任何错误或发生了什么? –

+0

它的工作原理。谢谢。 –