user4153231
user4153231

Reputation:

ng-repeat filter doesn't apply correctly

I have the following code:

Titre: <input ng-model="rechercheTitre">
Organisateur: <input ng-model="rechercheOrganisateur">
....
<li ng-repeat="resultats in resultatsJSON.results | filter:rechercheTitre"> 
    <span ng-bind-html="resultats.tra_title | highlight:rechercheTitre"></span>
    Organisateur(s) : {{resultOrganisateurs}}
</li>

My results is correctly display but the filter in ng-repeat is applied on rechercheTitre and rechercheOrganisateur. I only want the filter applied to rechercheTitre. How can i do that ?

Upvotes: 2

Views: 161

Answers (3)

user4153231
user4153231

Reputation:

Find the solution.

Correct answer is:

filter:{tra_type:rechercheType.tra_type}

Upvotes: 0

user4153231
user4153231

Reputation:

I have try:

filter:{rechercheTitre:rechercheTitre} 

no error in the console but when i put a letter on my rechercheTitre input, all the results are hiden. I have also test:

filter:{rechercheTitre:resultats.tra_title} 

no error in the console but in that case all the results are always displayed.

In case it help, here is how my json file is make:

{
  "count": 90,
  "results": [
  {
      "tra_speakers": "Jack"
      "tra_title": "test titre",
  }, ....

Upvotes: 0

dfsq
dfsq

Reputation: 193261

In this case you should use object notation:

ng-repeat="resultats in resultatsJSON.results | filter:{rechercheTitre: rechercheTitre}"

where you define by what properties (in this case rechercheTitre) array elements must be filtered.

Upvotes: 1

Related Questions