Is there something missing from the code you posted? You say you have two tables - I assume you are talking about some relational database? - that I don’t see anything about in the code. Also, what is this.service?
Ok, so you get the data from a remote webservice / API.
You either have to develop a endpoint that returns what you want to show, or see how you can transform the data you already get into the format you require.
What’s stopping you from doing that? What have you tried and what’s the problem you are facing?
Given their is a relation between the two tables (cause_id in OCCURENCES being an FK) and you are sending in a value through the argument cause_id in the navigateTo method that matches an actual causas.id value, it should be as simple as populating the occurencesList with the filtered objects by using a condition like this if(o.cause_id == this.cause_id)
By the way as @Sujan12 mentioned, it might be better to get the filtered list from the back end webservice itself.
That code snippet doesn’t make any sense. Show where it lives and tell us in plain English what you think it should do. Also, the error message is without any context. What is triggering it?
Please also include you ionic info output for good measure.
You could write a filterCities method that is executed behind a button. It takes this.cities, loops trough it and deletes all the cities that are not in the correct state. Then it writes the result in this.cities again which will update the list with the filtered city list.
(This is very dirty and probably not what you wnat, but implement it, get it to work and then go on to e.g. remove the button, create this list directly in initializeCities etc)
Always get in the habit of initializing all array and object properties, even if it is just to [] and {}. This will help you avoid bugs like this. Also, please give everything proper types instead of abusing any.
I don’t think the sort of filtering being done in getCitiesByIdState() belongs in a page controller, and I also think slinging the entire list of all cities around via NavParams is rather inefficient.
I would move all of that logic into the service provider, and pass only the state id in NavParams. It can also be written IMHO much more cleanly than the above loop like so:
If this becomes a performance bottleneck, it would also be feasible to presort all cities into a map indexed by state, which would eliminate the need to loop through all cities more than once at startup (assuming they don’t change while the app is running).