mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
68 lines
1.3 KiB
TypeScript
68 lines
1.3 KiB
TypeScript
import {Directive} from 'angular2/angular2';
|
|
import {NavController} from './nav-controller';
|
|
|
|
/**
|
|
* TODO
|
|
*/
|
|
@Directive({
|
|
selector: '[nav-push]',
|
|
properties: [
|
|
'navInstructions: navPush'
|
|
],
|
|
host: {
|
|
'(click)': 'onClick($event)',
|
|
'role': 'link'
|
|
}
|
|
})
|
|
export class NavPush {
|
|
/**
|
|
* TODO
|
|
* @param {NavController} nav TODO
|
|
*/
|
|
constructor(nav: NavController) {
|
|
this.nav = nav;
|
|
}
|
|
|
|
set navInstructions(instructions) {
|
|
if (instructions instanceof Array) {
|
|
if (instructions.length > 2) {
|
|
throw 'Too many [nav-push] arguments, expects [View, { params }]'
|
|
}
|
|
this.destination = instructions[0];
|
|
this.navParams = instructions[1];
|
|
} else {
|
|
this.destination = instructions;
|
|
}
|
|
|
|
//let annotations = Reflect.getMetadata('annotations', view);
|
|
// TODO check to make sure destination is a Component/IonicView?
|
|
}
|
|
|
|
onClick(event) {
|
|
this.nav.push(this.destination, this.navParams);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* TODO
|
|
*/
|
|
@Directive({
|
|
selector: '[nav-pop]',
|
|
host: {
|
|
'(click)': 'onClick($event)',
|
|
'role': 'link'
|
|
}
|
|
})
|
|
export class NavPop {
|
|
/**
|
|
* TODO
|
|
* @param {NavController} nav TODO
|
|
*/
|
|
constructor(nav: NavController) {
|
|
this.nav = nav;
|
|
}
|
|
onClick(event) {
|
|
this.nav.pop();
|
|
}
|
|
}
|