Ionic 3: Foo vs. FooPage

Seems there was a change in Ionic 3 that changed the class name of generated pages (ionic g page Foo) from “FooPage” to “Foo”:

2.3.0 foo.ts:

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

/*
  Generated class for the Foo page.

  See http://ionicframework.com/docs/v2/components/#navigation for more info on
  Ionic pages and navigation.
*/
@Component({
  selector: 'page-foo',
  templateUrl: 'foo.html'
})
export class FooPage {

  constructor(public navCtrl: NavController, public navParams: NavParams) {}

  ionViewDidLoad() {
    console.log('ionViewDidLoad FooPage');
  }

}

3.0.0 foo.ts:

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';

/**
 * Generated class for the Foo page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.
 */
@IonicPage()
@Component({
  selector: 'page-foo',
  templateUrl: 'foo.html',
})
export class Foo {

  constructor(public navCtrl: NavController, public navParams: NavParams) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad Foo');
  }

}

On one side this is just a naming change. But on the other side it is quite confusing especially if you started with Ionic 2 and now switched to Ionic 3. All the examples (and e.g. starter templates!) still use the old naming scheme, tutorials etc.

Is there anything more than naming to it that I missed?

i think this is a naming stuff…

if you asking me. i would never use the generators and would try to stay as close to the angular guidelines as possible for naming conventions.

The generators don’t do that?
(Can you provide a link to the Angular guidelines you mentioned?)

sure:

https://angular.io/styleguide#!#naming

1 Like

There a brief discussion about naming conventions here.

I don’t use the generators either. I just copy/paste from something I’ve already built with my own conventions which I mention in the link:

I didn’t find it useful to have everything named *.component.(ts|html) because then ~90% of my project would be component files without distinction.

Instead, I’ve taken to using *.page.(ts|html) and *.modal.(ts|html). I save *.component.(ts|html) for smaller pieces within my pages and modals. This is handy for searches (⌘P in VSCode, etc.) as well as eyeballing project structure in a file explorer.