Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html  ng-app>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body ng-controller="app">
  <button ng-click="add($index, item)" ng-repeat="item in phones">{{ item }}</button>
  <br>
  
  <!-- 如果newPhone有数量了,就显示呗 -->
  <span ng-show="newPhone.length">你已经选择了</span>
  
  <!-- 只显示newPhone的前两个 -->
  <a ng-repeat="newphone in newPhone | limitTo:2">{{ newphone }} </a>
  
  <!-- newPhone的数量大于2就显示... -->
  <span ng-show="newPhone.length > 2">...</span>
  
  <br>
  <br>
  <br>
  <small style="color:#999;">newPhone:{{ newPhone }}</small>
  <br>
  <small style="color:#999;">newPhone当前数量:{{ newPhone.length }}</small>
  <script>
    function app($scope) {
      $scope.phones = ['10010', '10086', '10000', '110', ' 120', '911'];
      
      $scope.newPhone = [];
      $scope.add = function (index, data) {
        $scope.newPhone.push(data);
        $scope.phones.splice(index, 1);
      }
        
    }
  </script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
hzplaypro
0viewers