From 8b07e6c55b4e57fc16ba51df3b91f978616422ec Mon Sep 17 00:00:00 2001
From: "Manu Mtz.-Almeida"
Date: Tue, 18 Oct 2016 01:38:42 +0200
Subject: [PATCH] fix(navPush): change detector exception
Disables prod mode in e2e tests
fixes
---
scripts/e2e/entry.ts | 2 --
src/components/nav/nav-pop.ts | 23 +++++++++----------
src/components/nav/nav-push.ts | 23 +++++++++----------
.../nav/test/nav-push-pop/app-module.ts | 1 +
.../nav/test/nav-push-pop/main.html | 7 ++++++
5 files changed, 30 insertions(+), 26 deletions(-)
diff --git a/scripts/e2e/entry.ts b/scripts/e2e/entry.ts
index 264bdbd47b..b225ca5be1 100644
--- a/scripts/e2e/entry.ts
+++ b/scripts/e2e/entry.ts
@@ -1,6 +1,4 @@
import { platformBrowser } from '@angular/platform-browser';
-import { enableProdMode } from '@angular/core';
import { AppModuleNgFactory } from './app-module.ngfactory';
-enableProdMode();
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
diff --git a/src/components/nav/nav-pop.ts b/src/components/nav/nav-pop.ts
index 26d029f892..a06a479d33 100644
--- a/src/components/nav/nav-pop.ts
+++ b/src/components/nav/nav-pop.ts
@@ -1,4 +1,4 @@
-import { AfterViewInit, Directive, HostBinding, HostListener, OnChanges, Optional } from '@angular/core';
+import { AfterContentInit, Directive, HostListener, Optional } from '@angular/core';
import { DeepLinker } from '../../navigation/deep-linker';
import { NavController } from '../../navigation/nav-controller';
@@ -57,32 +57,31 @@ export class NavPop {
* @private
*/
@Directive({
- selector: 'a[navPop]'
+ selector: 'a[navPop]',
+ host: {
+ '[attr.href]': '_href'
+ }
})
-export class NavPopAnchor implements OnChanges, AfterViewInit {
+export class NavPopAnchor implements AfterContentInit {
+
+ _href: string;
constructor(
@Optional() public host: NavPop,
public linker: DeepLinker,
@Optional() public viewCtrl: ViewController) {}
- @HostBinding() href: string;
-
updateHref() {
if (this.host && this.viewCtrl) {
const previousView = this.host._nav.getPrevious(this.viewCtrl);
- this.href = (previousView && this.linker.createUrl(this.host._nav, this.viewCtrl.component, this.viewCtrl.data)) || '#';
+ this._href = (previousView && this.linker.createUrl(this.host._nav, this.viewCtrl.component, this.viewCtrl.data)) || '#';
} else {
- this.href = '#';
+ this._href = '#';
}
}
- ngOnChanges() {
- this.updateHref();
- }
-
- ngAfterViewInit() {
+ ngAfterContentInit() {
this.updateHref();
}
diff --git a/src/components/nav/nav-push.ts b/src/components/nav/nav-push.ts
index 7fd884ec38..739b24e2dd 100644
--- a/src/components/nav/nav-push.ts
+++ b/src/components/nav/nav-push.ts
@@ -1,4 +1,4 @@
-import { AfterViewInit, Directive, Host, HostBinding, HostListener, Input, Optional, OnChanges } from '@angular/core';
+import { AfterContentInit, Directive, Host, HostListener, Input, Optional } from '@angular/core';
import { DeepLinker } from '../../navigation/deep-linker';
import { NavController } from '../../navigation/nav-controller';
@@ -84,30 +84,29 @@ export class NavPush {
* @private
*/
@Directive({
- selector: 'a[navPush]'
+ selector: 'a[navPush]',
+ host: {
+ '[attr.href]': '_href'
+ }
})
-export class NavPushAnchor implements OnChanges, AfterViewInit {
+export class NavPushAnchor implements AfterContentInit {
+
+ _href: string;
constructor(
@Host() public host: NavPush,
@Optional() public linker: DeepLinker) {}
- @HostBinding() href: string;
-
updateHref() {
if (this.host && this.linker) {
- this.href = this.linker.createUrl(this.host._nav, this.host.navPush, this.host.navParams) || '#';
+ this._href = this.linker.createUrl(this.host._nav, this.host.navPush, this.host.navParams) || '#';
} else {
- this.href = '#';
+ this._href = '#';
}
}
- ngOnChanges() {
- this.updateHref();
- }
-
- ngAfterViewInit() {
+ ngAfterContentInit() {
this.updateHref();
}
diff --git a/src/components/nav/test/nav-push-pop/app-module.ts b/src/components/nav/test/nav-push-pop/app-module.ts
index f1a06ad01f..337ee0f0b5 100644
--- a/src/components/nav/test/nav-push-pop/app-module.ts
+++ b/src/components/nav/test/nav-push-pop/app-module.ts
@@ -30,6 +30,7 @@ export class SecondPage {
export class E2EPage {
pushPage: any = SecondPage;
visible: boolean = false;
+ buttons: number[] = [1, 2, 3, 4, 5];
ionViewDidEnter() {
this.visible = true;
diff --git a/src/components/nav/test/nav-push-pop/main.html b/src/components/nav/test/nav-push-pop/main.html
index ef74bd30e4..3c81e3cd67 100644
--- a/src/components/nav/test/nav-push-pop/main.html
+++ b/src/components/nav/test/nav-push-pop/main.html
@@ -118,4 +118,11 @@
[navPush]="pushPage"
[navParams]="{msg:'a (a *ngIf=!visible)'}">a (a *ngIf="!visible")
+
+
+ a (*ngFor {{i}})
+
+