Navctrl.push a tapped item


Very newbie quesiton maybe, but I red that we can’t push string ?

console.log is showing the string, but nav push is crashing

Here’s my code :

import { Component } from '@angular/core';

import { NavController, NavParams } from 'ionic-angular';

import { Suites } from '../page3/suites/suites';

  selector: 'page-page3',
  templateUrl: 'page3.html'
export class Page3 {
  selectedItem: any;
  items: Array<{title: string, url:string}>;

  constructor(public navCtrl: NavController, public navParams: NavParams) {
    // If we navigated to this page, we will have an item available as a nav param
    this.selectedItem = navParams.get('item');

    this.items = [];

          this.items.push({title: 'Suites (4)', url:'Suites'});
          this.items.push({title: 'Intégration (2)',url:'integration'});
          this.items.push({title: 'Fonctions trigonométriques (4)',url:'fctrigo'});
          this.items.push({title: 'Exponentielle (2)',url:'expo'});
          this.items.push({title: 'Logarithme népérien (2)',url:'loga'});
          this.items.push({title: 'Étude de fonctions (2)',url:'etudefonction'});

  itemTapped(event, item) {

    this.navCtrl.push( item.url, {
      item: item


You can’t push through an object, only strings.
You could json it I guess but better to pass an ID through.


What should I do, a new function ?


I’m not sure what @codiqa100031834 is talking about, but if you want to pass strings to the navigation system, you must adopt lazy page loading as described here.


I did say you can pass strings and yes deep linking needs to be in place.


What did you mean by “you can’t push through an object”?


Actually I think I have that wrong - I use deep linking a LOT (apologies it’s how my mind works) so I never rely on anything other than what’s in the URL bar.

You’re absolutely right you can pass through a full object. Would still prefer a service layer handling those objects but nay probs in either case.