when I use angular router to change the view,it makes an error at
NavControllerBase.prototype.getActive = function () {
return this._views[this._views.length - 1];
};
this._views is null.
but It is fine at 2.1.0
here is my code:
navigate:
this.router.navigate(['/home']);
home.component.ts:
import { Component } from '@angular/core';
import { RecommendPage } from './recommend/recommend.component';
@Component({
template: '<ion-nav [root]="rootPage"></ion-nav>'
})
export class HomeComponent {
// First page to push onto the stack
rootPage = RecommendPage;
}
I don’t believe use of the Angular router is supported with Ionic.
It is working very well, until I updated to 2.2.0 last night.
angular router code:
app-routing.module
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
const appRoutes: Routes = [
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
}
];
@NgModule({
declarations: [
],
imports: [
RouterModule.forRoot(appRoutes),
],
exports: [
RouterModule
]
})
export class AppRoutingModule {}
home.module.ts
import { NgModule } from '@angular/core';
import { IonicModule } from 'ionic-angular';
import { RouterModule, Routes } from '@angular/router';
import { AuthGuard } from '../../services/auth.module';
import { HomeComponent } from './home.component';
import { RecommendPage } from './recommend/recommend.component';
import { FootNavModule } from '../foot/foot-nav.module';
import { HomeService } from './home.service';
const homeRoutes: Routes = [
{ path: 'home', component: HomeComponent, canActivate: [AuthGuard] }
];
@NgModule({
declarations: [
HomeComponent,
RecommendPage
],
imports: [
FootNavModule,
RouterModule.forChild(homeRoutes),
IonicModule
],
entryComponents: [
HomeComponent,
RecommendPage
],
providers: [HomeService]
})
export class HomeModule {
constructor() {
console.log('init HomeModule');
}
}