当我们向其他子搜索输入 - AngularJS输入任何值时,避免[object Object]坐在主搜索输入中

时间:2016-09-24 04:42:11

标签: javascript html angularjs

  1. 我正在使用多列搜索过滤器,在下面的示例中,我创建了两个用于搜索的输入。一个用于完全搜索,另一个用于学生ID搜索。每当我输入学生ID字段的值时,[object Object]将位于完整的搜索字段

  2. 如果完整搜索字段中存在任何值,则表示我们无法为提交的学生ID输入值。

  3. 请帮助我,提前致谢

    <div ng-app="app" ng-controller="myCtlr">
     <input type="text" ng-model="search" placeholder="Search All">
     <input type="text" ng-model="search.student_id" placeholder="Student ID">
     <table>
      <tr ng-repeat="student in student_data|filter:search|limitTo:'10'">
        <td>{{student.table}}</td>
        <td>{{student.student_id}}</td>
        <td>{{student.name}}</td>
      </tr>
     </table>
    <div>
    <script>
    var app = angular.module('app',[]);
    app.controller('myCtlr',function($scope, $http){
        $scope.student_data = 
    [{"student_id":"12508","name":"AKILA","course":"MCA","course_fee":"0","percentage":"85","University":"","partner":"guru","infocenter":"","father":"","mobile":"1234525411","sem":"2","table":"noble_table","total_paid":"2500"}]
    });
    <script>
    

    检查我的JSFiddle example

2 个答案:

答案 0 :(得分:1)

这是因为您将search.studentid绑定到完整搜索,使用。$作为第一个

<input type="text" ng-model="search.$" placeholder="Full search">
<input type="text" ng-model="search.student_id" placeholder="student id">
<table>

DEMO

但如果您正在处理如此多的个人财产搜索,那么以下将是最好的方式

<强> UPDATED DEMO

答案 1 :(得分:1)

您需要在此处添加$

<input type="text" ng-model="search.$" placeholder="Full search">

请检查the doc