mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-17 02:31:34 +08:00
feat(routerDirection): refactors goBack
This commit is contained in:
@ -5,7 +5,7 @@ export { RadioValueAccessor } from './control-value-accessors/radio-value-access
|
||||
export { SelectValueAccessor } from './control-value-accessors/select-value-accessor';
|
||||
export { TextValueAccessor } from './control-value-accessors/text-value-accessor';
|
||||
|
||||
export { GoBack } from './navigation/go-back';
|
||||
export { RouterDirection } from './navigation/router-direction';
|
||||
export { IonBackButton } from './navigation/ion-back-button';
|
||||
export { NavDelegate } from './navigation/nav-delegate';
|
||||
export { TabDelegate } from './navigation/tab-delegate';
|
||||
|
@ -1,17 +0,0 @@
|
||||
import { Directive, HostListener } from '@angular/core';
|
||||
import { NavController, NavIntent } from '../../providers/nav-controller';
|
||||
|
||||
@Directive({
|
||||
selector: '[goBack]',
|
||||
})
|
||||
export class GoBack {
|
||||
|
||||
constructor(
|
||||
private navCtrl: NavController,
|
||||
) {}
|
||||
|
||||
@HostListener('click')
|
||||
onClick() {
|
||||
this.navCtrl.setIntent(NavIntent.Back);
|
||||
}
|
||||
}
|
28
angular/src/directives/navigation/router-direction.ts
Normal file
28
angular/src/directives/navigation/router-direction.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { Directive, HostListener, Input } from '@angular/core';
|
||||
import { NavController, NavIntent } from '../../providers/nav-controller';
|
||||
|
||||
@Directive({
|
||||
selector: '[routerDirection]',
|
||||
})
|
||||
export class RouterDirection {
|
||||
|
||||
@Input() routerDirection: string;
|
||||
|
||||
constructor(
|
||||
private navCtrl: NavController,
|
||||
) {}
|
||||
|
||||
@HostListener('click')
|
||||
onClick() {
|
||||
this.navCtrl.setIntent(textToIntent(this.routerDirection));
|
||||
}
|
||||
}
|
||||
|
||||
function textToIntent(direction: string) {
|
||||
switch (direction) {
|
||||
case 'forward': return NavIntent.Forward;
|
||||
case 'back': return NavIntent.Back;
|
||||
case 'root': return NavIntent.Root;
|
||||
default: return NavIntent.Auto;
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -94,9 +94,9 @@ const DECLARATIONS = [
|
||||
c.TextValueAccessor,
|
||||
|
||||
// navigation
|
||||
c.GoBack,
|
||||
c.IonBackButton,
|
||||
c.IonRouterOutlet,
|
||||
c.RouterDirection,
|
||||
c.NavDelegate,
|
||||
c.TabDelegate,
|
||||
c.TabsDelegate,
|
||||
|
Reference in New Issue
Block a user