首页 > 如何在页面中把ng-repeat遍历出来的xxx.yyy(字符串) ,过滤成数组

如何在页面中把ng-repeat遍历出来的xxx.yyy(字符串) ,过滤成数组


<tr ng-repeat="ins in  instances">
  <td ><input type="checkbox" ng-model="icheckedList[ins.id]" ng-required="{{needOneList}}" ng-checked="all" one-least></td>
  <td><span ng-bind="ins.name"></span></td>
  <td><table><tr ng-repeat="p in ins.private_ip|privateip"></tr></table></td>
  <td ng-bind="ins.public_ip"></td>
</tr>

.filter('privateip',function() {
    return function(p) {
        p.split(',');
        return p
    }
})

其中 ins.private_ip是一个 形如 1.2.3.4,94.8.7.6 的字符串
怎么才能把 ins.private_ip 过滤成列表 p in ins.private_ip|privateip似乎是过滤的遍历出来的p?


过滤成列表的意思是?你这是要干嘛?我可以先给你改改,只是不知道这是做什么:

<tr ng-repeat="ins in  instances">
  <td ><input type="checkbox" ng-model="icheckedList[ins.id]" ng-required="{{needOneList}}" ng-checked="all" one-least></td>
  <td><span ng-bind="ins.name"></span></td>
  <td>
      <table>
          <tr ng-repeat="p in ins.private_ip">
              <!-- 这里输出的就是数组了 -->
              {{ p | privateip }}
          </tr>
      </table>
  </td>
  <td ng-bind="ins.public_ip"></td>
</tr>

.filter('privateip',function() {
    return function(p) {
        p.split(',');
        return p
    }
})
【热门文章】
【热门文章】