feat(nav): params

This commit is contained in:
Manu Mtz.-Almeida
2018-03-08 10:50:18 +01:00
parent 4a3030f087
commit 878d7e64b0
2 changed files with 8 additions and 18 deletions

View File

@ -619,14 +619,9 @@ export class NavControllerBase implements NavOutlet {
// render the component ref instance to the DOM // render the component ref instance to the DOM
// ******** DOM WRITE **************** // ******** DOM WRITE ****************
this.el.appendChild(view.element); this.el.appendChild(view.element);
view._state = STATE_ATTACHED; view._state = STATE_ATTACHED;
// TODO: fails in test
if (view._cssClass) {
// the ElementRef of the actual ion-page created
// ******** DOM WRITE ****************+
view.element.classList.add(view._cssClass);
}
// successfully finished loading the entering view // successfully finished loading the entering view
// fire off the "didLoad" lifecycle events // fire off the "didLoad" lifecycle events
view._didLoad(); view._didLoad();

View File

@ -30,7 +30,6 @@ export class ViewController {
_nav: NavControllerBase; _nav: NavControllerBase;
_zIndex: number; _zIndex: number;
_state: number = STATE_NEW; _state: number = STATE_NEW;
_cssClass: string;
/** @hidden */ /** @hidden */
id: string; id: string;
@ -44,15 +43,8 @@ export class ViewController {
constructor( constructor(
public component: any, public component: any,
public data?: any, public data?: any
rootCssClass: string = DEFAULT_CSS_CLASS ) {}
) {
// component could be anything, never use it directly
// it could be a string, a HTMLElement
// passed in data could be NavParams, but all we care about is its data object
// this.data = (data instanceof NavParams ? data.data : (isPresent(data) ? data : {}));
this._cssClass = rootCssClass;
}
/** /**
* @hidden * @hidden
@ -65,6 +57,11 @@ export class ViewController {
this.element = (typeof component === 'string') this.element = (typeof component === 'string')
? document.createElement(component) ? document.createElement(component)
: component; : component;
this.element.classList.add('ion-page');
if (this.data) {
Object.assign(this.element, this.data);
}
} }
_setNav(navCtrl: NavControllerBase) { _setNav(navCtrl: NavControllerBase) {
@ -322,5 +319,3 @@ export class ViewController {
export function isViewController(viewCtrl: any): viewCtrl is ViewController { export function isViewController(viewCtrl: any): viewCtrl is ViewController {
return !!(viewCtrl && (<ViewController>viewCtrl)._didLoad && (<ViewController>viewCtrl)._willUnload); return !!(viewCtrl && (<ViewController>viewCtrl)._didLoad && (<ViewController>viewCtrl)._willUnload);
} }
const DEFAULT_CSS_CLASS = 'ion-page';