Skip to content

Commit

Permalink
fix(nav): fix menuCtrl reference in swipe back
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Jun 30, 2016
1 parent 76619cf commit 55a5e83
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/components/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export class App {
/**
* @private
*/
getComponent(id: string): any {
private getComponent(id: string): any {
// deprecated warning: added 2016-04-28, beta7
console.warn('Using app.getComponent() to query components has been deprecated. ' +
'Please use Angular\'s ViewChild annotation instead:\n\nhttp://learnangular2.com/viewChild/');
Expand All @@ -259,7 +259,7 @@ export class App {
* Get an instance of the global app injector that contains references to all of the instantiated providers
* @returns {Injector}
*/
getAppInjector(): any {
private getAppInjector(): any {
// deprecated warning: added 2016-06-27, beta10
console.warn('Recent Angular2 versions should no longer require App.getAppInjector()');
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/app/test/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,15 +446,15 @@ describe('App', () => {
var _cd: any;

function mockNav(): Nav {
return new Nav(null, null, null, config, null, null, null, null, null);
return new Nav(null, null, null, config, null, null, null, null, null, null);
}

function mockTabs(): Tabs {
return new Tabs(null, null, null, config, null, null, null);
}

function mockTab(parentTabs: Tabs): Tab {
var tab = new Tab(parentTabs, app, config, null, null, null, null, null, _cd);
var tab = new Tab(parentTabs, app, config, null, null, null, null, null, _cd, null);
parentTabs.add(tab);
tab.root = SomePage;
tab.load = function(opts: any, cb: Function) {
Expand Down
6 changes: 3 additions & 3 deletions src/components/nav/nav-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ export class NavController extends Ion {
elementRef: ElementRef,
protected _zone: NgZone,
protected _renderer: Renderer,
protected _compiler: ComponentResolver
protected _compiler: ComponentResolver,
protected _menuCtrl: MenuController
) {
super(elementRef);

Expand Down Expand Up @@ -1532,8 +1533,7 @@ export class NavController extends Ion {
edge: 'left',
threshold: this._sbThreshold
};
let menuCtrl = this._app.getAppInjector().get(MenuController);
this._sbGesture = new SwipeBackGesture(this.getNativeElement(), opts, this, menuCtrl);
this._sbGesture = new SwipeBackGesture(this.getNativeElement(), opts, this, this._menuCtrl);
}

if (this.canSwipeBack()) {
Expand Down
4 changes: 3 additions & 1 deletion src/components/nav/nav-portal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ComponentResolver, Directive, ElementRef, forwardRef, Inject, NgZone, O
import { App } from '../app/app';
import { Config } from '../../config/config';
import { Keyboard } from '../../util/keyboard';
import { MenuController } from '../menu/menu-controller';
import { NavController } from '../nav/nav-controller';

/**
Expand All @@ -20,9 +21,10 @@ export class NavPortal extends NavController {
zone: NgZone,
renderer: Renderer,
compiler: ComponentResolver,
menuCtrl: MenuController,
viewPort: ViewContainerRef
) {
super(null, app, config, keyboard, elementRef, zone, renderer, compiler);
super(null, app, config, keyboard, elementRef, zone, renderer, compiler, menuCtrl);
this.isPortal = true;
this.setViewport(viewPort);
app.setPortal(this);
Expand Down
6 changes: 4 additions & 2 deletions src/components/nav/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { App } from '../app/app';
import { Config } from '../../config/config';
import { Keyboard } from '../../util/keyboard';
import { isTrueProperty } from '../../util/util';
import { MenuController } from '../menu/menu-controller';
import { NavController } from './nav-controller';
import { ViewController } from './view-controller';

Expand Down Expand Up @@ -126,9 +127,10 @@ export class Nav extends NavController implements AfterViewInit {
elementRef: ElementRef,
zone: NgZone,
renderer: Renderer,
compiler: ComponentResolver
compiler: ComponentResolver,
menuCtrl: MenuController
) {
super(parent, app, config, keyboard, elementRef, zone, renderer, compiler);
super(parent, app, config, keyboard, elementRef, zone, renderer, compiler, menuCtrl);

if (viewCtrl) {
// an ion-nav can also act as an ion-page within a parent ion-nav
Expand Down
6 changes: 4 additions & 2 deletions src/components/tabs/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { App } from '../app/app';
import { Config } from '../../config/config';
import { isTrueProperty} from '../../util/util';
import { Keyboard} from '../../util/keyboard';
import { MenuController } from '../menu/menu-controller';
import { NavController} from '../nav/nav-controller';
import { NavOptions} from '../nav/nav-options';
import { TabButton} from './tab-button';
Expand Down Expand Up @@ -227,10 +228,11 @@ export class Tab extends NavController {
zone: NgZone,
renderer: Renderer,
compiler: ComponentResolver,
private _cd: ChangeDetectorRef
private _cd: ChangeDetectorRef,
menuCtrl: MenuController
) {
// A Tab is a NavController for its child pages
super(parent, app, config, keyboard, elementRef, zone, renderer, compiler);
super(parent, app, config, keyboard, elementRef, zone, renderer, compiler, menuCtrl);

parent.add(this);

Expand Down

0 comments on commit 55a5e83

Please sign in to comment.