App doesn't work with real device / emulator / SOLVED (pipe issue)


#1

I have a problem with my android app. It works perfectly when I run it in the browser, but when run it in real device or emulator some pages won’t open at all or their layout is messed up. When I press the button multiple times which should open the new window and then press back-button, page opens, but layout is totally broken. Android emulator doesn’t log any errors.

Is there any common causes for this kind of behaviour?

Not working pages are not static, all of them have some data bound to layout, but as I said, no problems when used with ‘ionic serve’.


#2

Ok, I located the problem.

Currency and date pipes doesn’t work. My own pipes works okay, so maybe I have to code them my own.


#3

I noticed this as well. I had to create my own custom date pipe, otherwise my view broke.

I didn’t have time to investigate whether it was an Angular or Ionic Issue.

¯_(ツ)_/¯


#4

@andrewgy8 , can you please share your date pipe ?


#5

Here is mine if it helps. I use it like this {{ isoDateString | dateFormat: ‘dd.mm.yyyy’ }}. I use moment to format my dates.

import { Injectable, Pipe } from '@angular/core';
import moment from 'moment';

@Pipe({
  name: 'dateFormat'
})
@Injectable()
export class DateFormat {
  transform(date: string, format: string): string {
     let d = new Date(date);

    switch (format.toUpperCase()) {
      case 'DD.MM.YYYY':
        return moment(d).format('DD.MM.YYYY');
      default:
        return 'Unknown date format';
    }
  }
}