How to take an array of a table and search another table in Ionic and Angularjs

Asked

Viewed 146 times

0

I have a field on a table with a array number:

2;3;7;8;9;10;11;15;1

Each of these numbers corresponds to an ID of another table. I need to list the items of this other table according to the array. I’m failing to arrive at a favorable logic.

Some solution?

  • It was not very clear to me when you say "another table". Is this data in an array, object array? If so, could you use the filter.

  • @Branches this array of numbers is separated with ; same?

  • Was any of the answer helpful? Don’t forget to choose one and mark it so it can be used if someone has a similar question!

1 answer

1


I made a plunker to try to exemplify. See if this is what you need.

  • Hello Danilo, I think what he wants is the opposite, he wants to take everything related to the first array

  • Oops, good afternoon. In that case he can change the condition.

  • @Danilosilva His example was perfect. But look at Plunk I did about what I’m trying to do. There is something very wrong with my code: https://plnkr.co/edit/Ovg4WHLTdNeOM9Eeae8c?p=preview

  • @Danilosilva I also tried: for (var i = 0; i < $Scope.array2.length; i++){ if ( $Scope.array1.indexof(parseint($Scope.array2[i].categoria_comida_cod_categoria_com)) >= 0 ){ $Scope.array3.push($Scope.array2[i]); } }

  • But even result.

  • @Ramos, there were some inconsistencies in your code. See code [link]http://plnkr.co/edit/2q1dYUsIscHXiv6dbBMR?p=preview with the correction. Now just make the logic as per your need.

  • Guys, thank you so much! :))))

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.