I get confused with passing variables in the new version


I made an App with framework7 v.1 which was simple.

The index.html had a few cards with this code:

<div class="card card-header-pic irAtexto" data-id="99">

then a click event with this code:

$$('.irAtexto').on('click', function(){
  // ------ tomamos el "id" de la card en la que hemos hecho click.
  var id = $$(this).attr('data-id');
  // ------ abrimos texto.html con los datos de "id".

and append the info in the LocalStorage with this code:

myApp.onPageInit('textos', function(page){
  var id = page.query.id;

And with framework7 v.2, the new routes, and so on… I don’t manage to find a simple way to do this.

Could you help me?


In routes:

  path: 'texto',
  url: 'texto.html',

and then just call mainView.router.navigate('texto?id=...');

Thanks for your answer. I have solved it by using the route: ‘details?id=’ + i
Where ‘i’ is the variable used for the contacts array.

Now I am facing a similar problem.

In the page contacts.html I list all the contacts by its name using the function navigator.contacts.find (it is from the plugin cordova-plugin-contacts). It works very well. And I generate a link for each contact like this:

'<a href="details?i=' + i + '" id="contacto" class="item-content item-link">'

The link works ok and opens details.html with the value within the query for ‘i’. I manage to get the ‘i’ value. But when I try to get values from contacts[i] … it doesn’t work. It seems that the object ‘contacts’ is only available while in contacts.html (the list of contacts), but when I change to details.html… I can not get anything from it.

Can you help me solving it?

How did you get contacts in your details page? Apparently you must do it in same way as on contacts list page

Sorry, I have discovered the method: navigator.contacts.pickContact() and it was the thing I was looking for.

It just picks a contact and receives the object of the information that belongs to the contact picked.