【发布时间】:2018-09-11 16:16:49
【问题描述】:
一个月前,我开始了一个 Ionic 项目,我决定使用空白模板,但是在创建了几个页面之后,我需要在底部制作一个导航栏,就像标签模板上的导航栏一样。
我尝试创建自己的navbar 组件,但是当我将它放在主页上时,应用程序开始加载很长时间,并让我的资源管理器停止工作。
谁能告诉我为什么会这样?
我认为我的另一个选择是更改模板并使用默认具有导航功能的模板,但是我可以更改模板并保留我所做的一切吗?
app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import {LoginComponent} from '../components/login/login';
import { UserProvider } from '../providers/user/user';
import {HttpClientModule} from "@angular/common/http";
import {SigningUpPage} from "../pages/signingUp/signingUp";
import { MunicipalitiesProvider } from '../providers/municipalities/municipalities';
import {ViewProfilePage} from "../pages/view-profile/view-profile";
import {NavbarTabsComponent} from "../components/navbar-tabs/navbar-tabs";
@NgModule({
declarations: [
MyApp,
HomePage,
LoginComponent,
SigningUpPage,
ViewProfilePage,
NavbarTabsComponent
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
HttpClientModule
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage,
SigningUpPage,
ViewProfilePage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
UserProvider,
MunicipalitiesProvider,
]
})
export class AppModule {}
home.html:
<login *ngIf="name == null"></login>
<page-view-profile *ngIf="name != null"></page-view-profile>
<navbar-tabs></navbar-tabs>
导航栏-tabs.html:
<ion-tabs>
<ion-tab [root]="home" tabTitle="Inicio" tabIcon="home"></ion-tab>
<ion-tab [root]="profile" tabTitle="Perfil" tabIcon="person"></ion-tab>
</ion-tabs>
导航栏-tabs.ts:
import { Component } from '@angular/core';
import {HomePage} from "../../pages/home/home";
import {ViewProfilePage} from "../../pages/view-profile/view-profile";
@Component({
selector: 'navbar-tabs',
templateUrl: 'navbar-tabs.html'
})
export class NavbarTabsComponent {
home = HomePage;
profile = ViewProfilePage;
constructor() {
}
ionViewDidLoad(){
console.log('Hello');
}
}
该应用位于导航栏分支上的this repo。
【问题讨论】:
标签: angular typescript ionic-framework ionic2