fix(navPush): change detector exception

Disables prod mode in e2e tests

fixes
This commit is contained in:
Manu Mtz.-Almeida
2016-10-18 01:38:42 +02:00
parent a4635ec690
commit 8b07e6c55b
5 changed files with 30 additions and 26 deletions

View File

@@ -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);

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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;

View File

@@ -118,4 +118,11 @@
[navPush]="pushPage"
[navParams]="{msg:'a (a *ngIf=!visible)'}">a (a *ngIf="!visible")</a>
</p>
<p *ngFor="let i of buttons">
<a
[navPush]="pushPage"
[navParams]="{msg:'ngFor'}">a (*ngFor {{i}})</a>
</p>
</ion-content>