2016-09-20 41 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

它的工作原理。謝謝。 –