Skip to content

Commit

Permalink
fix(navPush): change detector exception
Browse files Browse the repository at this point in the history
Disables prod mode in e2e tests

fixes
  • Loading branch information
manucorporat committed Oct 17, 2016
1 parent a4635ec commit 8b07e6c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
2 changes: 0 additions & 2 deletions scripts/e2e/entry.ts
Original file line number Diff line number Diff line change
@@ -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);
23 changes: 11 additions & 12 deletions src/components/nav/nav-pop.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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();
}

Expand Down
23 changes: 11 additions & 12 deletions src/components/nav/nav-push.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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();
}

Expand Down
1 change: 1 addition & 0 deletions src/components/nav/test/nav-push-pop/app-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/components/nav/test/nav-push-pop/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit 8b07e6c

Please sign in to comment.