Problem with viewController in IOS


#1

I have fully functional code when i run my ionic application with

ionic lab
ionic emulate ios --prod

but the problem is when i upload it to ionic view OR
if i try to run the app with the following command

ionic emulate ios --prod -lcs // livereload server logs and console logs

Anyways i can’t seem to find the problem or a good way to debug it, here is the code that isn’t working. Basically there are 2 components talking to each other with events. The goal of the components are to have a overlay image helping the user to navigate in the app.

Component 1

import { Component } from '@angular/core';
import { NavController, Events, ViewController } from 'ionic-angular';

@Component({
  selector: 'help',
  templateUrl: 'help.html'
})
export class HelpComponent {

  private img : any;
  private hide = true

  private helpers =  {
    "AccountPage": "/assets/helpers/mitt-konto.png",
    "PaymentPage": "/assets/helpers/betalningsinformation.png",
    "HomePage": "/assets/helpers/kommande-matcher.png",
    "GamePage": "/assets/helpers/matchdetaljer.png",
    "SupportYourTeamPage": "/assets/helpers/kop-andelar.png",
    "MyTeamsPage": "/assets/helpers/mina-lag.png",
    "CompletedMatchPage": "/assets/helpers/avslutade-matcher.png",
    "SettingsPage": "/assets/helpers/uppdatera-sidan.png"
  }

  constructor(
    public viewCtrl: ViewController,
    public events : Events
  ){
    this.events.subscribe('showOverlay:'+this.viewCtrl.name, (name) => {
      this.img = this.helpers[name]
      this.hide = false
    })
  }
}

Component 2

import { Component, Input } from '@angular/core';
import { Events, NavController } from 'ionic-angular';

@Component({
  selector: 'my-header',
  templateUrl: 'header.html'
})
export class HeaderComponent {
  
  @Input('title') title: string;
  constructor(public events: Events, public navCtrl: NavController) {}

  showHelp(){
      this.events.publish('showOverlay:'+this.navCtrl.getActive().name, this.navCtrl.getActive().name);
  }
}


#2

When you say you cannot find a good way of debugging this do you mean in terms of having the minified js code to plough through?

If so two suggestions:

  1. Don’t include --prod in your output
  2. On your showHelp() function, add in the word debugger; as the first line. If you have Safari open with the debugging tools it should stop at this point and allow you to step through.

#3

Did you remote debug the problem on the device already? Follow these instructions here to debug the problem in Safari dev tools: https://ionic.zone/debug/remote-debug-your-app#ios Look at the console and network tabs for errors.