Home  >  Article  >  Web Front-end  >  Introduction to ionic2 lazy loading configuration

Introduction to ionic2 lazy loading configuration

巴扎黑
巴扎黑Original
2017-09-02 13:23:231391browse

This article mainly introduces the detailed explanation of ionic2 lazy loading configuration. The editor thinks it is quite good. Now I will share it with you and give it as a reference. Let’s follow the editor and take a look.

The title of the article is part 1, and it explains that it can be configured in this way currently, but there may be changes in subsequent use.

Take the ion-cli default home component as an example. Add the home.module.ts file


import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { HomePage } from './home';
@NgModule({
 declarations: [HomePage],
 imports: [IonicPageModule.forChild(HomePage)],
 exports: [HomePage]
})
export class HomePageModule { }

Modify home.ts, mainly to add IonicPage. For its configuration items, please refer to the official documentation.


import { Component } from '@angular/core';
import { IonicPage } from 'ionic-angular';
@IonicPage()
@Component(... )
export class HomePage { ... }

Modify app.component.ts, change HomePage to 'HomePage', delete app.module.ts and the import { HomePage } used in other pages from '.. /pages/home/home'; Because this is no longer needed, just quote the string directly where needed.


rootPage:any = 'HomePage';

ionic serve If you see files similar to the following, it means success.

The above is the detailed content of Introduction to ionic2 lazy loading configuration. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn