1

我的东西在角度上正常工作

   Any: <input ng-model="search.$"> 
   Student Name only <input ng-model="search.number">
   student Region only <input ng-model="search.region">

和这个

<li ng:repeat="students in student | filter:search"  >

但我想把这三个搜索框变成一个搜索框并像这样选择框

  Any: <input ng-model="search.$"> 

<select>
  <option value="number">Student Number</option>
  <option value="region">Student Region</option>

</select> 

我也想在用户点击搜索按钮时执行搜索

我怎样才能做到这一点

4

1 回答 1

0

search当用户点击按钮时,您可以设置您的值。现场样本: http: //plnkr.co/edit/jTRmBH

模板:

 <label>
 Search Value: <input ng-model="filter">*emphasized text*
 </label><br>
 <label>
 Search Key:
 <select ng-model="key">
   <option value="$">Any</option>
   <option value="number">Student Number</option>
   <option value="region">Student Region</option>
 </select> 
 </label>
 <button ng-click="setfilter()">search</button>

javascript:

$scope.setfilter = function() {
  $scope.search = {};
  $scope.search[ $scope.key ] = $scope.filter;
  console.log( $scope.search );
};
于 2013-03-26T03:12:08.533 回答