0

$scope から入力されたテーブルと、ユーザー名と電子メールをフィルター処理するために使用しているヘッダーの 2 つの検索テキスト ボックスがあります。

<table class="table">
<thead>
<tr>
    <th></th>
    <th><input type="search" placeholder="Search" ng-model="searchName"></th>
    <th><input type="search" placeholder="Search" ng-model="searchMail"> </th>
    <th></th>
</tr>
<tr>
    <th>ID</th>
    <th>Name</th>
    <th>email</th>
    <th>password</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="q in dataForTable | filter:{user_fullname : searchName, user_email : searchMail}">
    <td>{{q.user_id}}</td>
    <td>{{q.user_fullname}}</td>
    <td>{{q.user_email}}</td>
    <td>{{q.user_password}}</td>
</tr>
</tbody>    

dataForTable は $http 経由でコントローラーから取得されます。

$http.get('http://tbrzica.comli.com/rest/index.php/simple/users').success(function(data){
   $scope.dataForTable=data;
});

しかし、ページが最初にロードされるとき、テーブルは空です。テキストボックスに何かを書いて入力を削除した場合にのみ、テーブルが作成され、両方の条件による検索が正常に機能します。これは何かのバグですか?
前もって感謝します。

編集:解決策が見つかりました:

コントローラー内で 2 つの ng-model パラメーターを初期化する必要がありました。

$scope.searchName="";
$scope.searchhMail="";

timeJV さん、ご回答ありがとうございます。

4

1 に答える 1