search

Home  >  Q&A  >  body text

angular.js - How to filter the xxx.yyy (string) traversed by ng-repeat into an array in the page


<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
    }
})

Where ins.private_ip is a string in the form of 1.2.3.4,94.8.7.6
How can ins.private_ip be filtered into a list p in ins.private_ip|privateip seems to be the p that is filtered and traversed?

淡淡烟草味淡淡烟草味2779 days ago622

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-05-15 17:04:33

    What does filtering into a list mean? What are you doing? I can change it for you first, but I don’t know what it does:

    <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
        }
    })

    reply
    0
  • Cancelreply