Module.ts ionic 2

0
I've updated ionic 2 and angular, but now when I generate a page it automatically creates a file module.ts inside the page folder along with the html, scss and ts file, does anyone know how to make the application work? because when I try to load with ionic serve error appears just not recognizing this module.ts of the page created, does anyone have any solution?

    
asked by anonymous 19.04.2017 / 00:17

1 answer

0

This new file module is for lazy loading (which from my point of view has greatly improved performance).

If you do not want to use lazy loading and continue with the ionic as it was just delete this module file and in your HTML delete the @IonicPage selector that it also places, then you do your routine to add the page in app.modules.ts and follow life.

If you want to leave the file and do lazy loading, do the following:

Leave your file paginaNova.module.ts like this:

import { NgModule } from '@angular/core';
import { NovaPagina} from './NovaPagina';
import { IonicPageModule } from 'ionic-angular'; // ele cria com IonicModule e isso da erro, tem que ser IonicPageModule

@NgModule({
    declarations: [NovaPagina],
    imports: [IonicPageModule.forChild(NovaPagina)],
    exports: [NovaPagina]
})
export class NovaPaginaModule { } //tem que ser assim: nomeDaPaginaModule

You do not need to import this page into your app.module.ts and pages when calling this new page, just use its name inside quotation marks, then a new page push that was

import { NovaPagina } from '../novaPagina';

mInhaFuncao(){
  this.navCtrl.push(NovaPagina);
}

It becomes

mInhaFuncao(){ // Não precisa mais importar a página.
  this.navCtrl.push("NovaPagina");
}

Do this for all pages of the project and be happy, just create a module for home page and import IonicPage into pagina.ts and put it under @Component. It's a little work, but it's worth it.

I hope I have helped: D

    
27.04.2017 / 22:15