javascript - AngularJS filter by two fields -


i trying use analogously code filter tasks, doesn't work properly. if i'm using 1 filter it's ok ( no matter 1 i'm using ). when try filter second input doesn't work.

moreover: when delete string first input , try filter second doesn't work @ all.

<div>     filters: <br />     company: <input ng-model="search.project.company.name_company"> <br />     project: <input ng-model="search.project.project_name"> <br /> </div> <table>     <th>lp.</th>     <th ><a href="" ng-click="sortby='project.company.name_company'">company</a></th>     <th><a href="" ng-click="sortby='project.project_name'">project</a></th>     <th><a href="" ng-click="sortby='time_start'">time start</a></th>     <th><a href="" ng-click="sortby='time_stop'">time stop</a></th>     <th><a href="" ng-click="sortby='time_start-time_stop'">work time</a></th>     <tr ng-repeat="task in tasks | filter:search | orderby:sortby " class="thumbnail">         <td >{[{ $index+1 }]}</td>         <td >{[{ task.project.company.name_company }]}</td>         <td >{[{ task.project.project_name }]}</td>         <td >{[{ task.time_start | date : 'y-mm-dd hh:mm' }]}</td>         <td >{[{ task.time_stop | date : 'y-mm-dd hh:mm' }]}</td>         <td>{[{ timediff(task.time_start,task.time_stop) }]} godzin</td>         <td><button ng-click="edit(task)">edit</button></td>         <td><button ng-click="delete(task)">delete</button></td>     </tr> </table> 

edit: plunker - http://plnkr.co/edit/vdkfnkgpdlup9rgz1ivo?p=preview

try adding search properties 1 level higher on search object? instead of

<input ng-model="search.project.company.name_company"> <br />     project: <input ng-model="search.project.project_name"> <br /> 

use:

<input ng-model="search.company.name_company"> <br />     project: <input ng-model="search.project_name"> <br /> 

or try switching filter

<tr ng-repeat="task in tasks | filter:search | orderby:sortby " class="thumbnail"> 

to:

<tr ng-repeat="task in tasks | filter:search.project | orderby:sortby " class="thumbnail"> 

or write custom filter.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -