feat(button): goback attribute

This commit is contained in:
Manu Mtz.-Almeida
2018-03-27 12:05:09 +02:00
parent a428fdc48c
commit 00fc460c4e
9 changed files with 51 additions and 10 deletions

View File

@@ -1,5 +1,4 @@
import { CssClassMap } from '../index';
import { RouterDirection } from '../components/router/utils/interfaces';
/**
* Create the mode and color classes for the component based on the classes passed in
@@ -66,14 +65,13 @@ export function getClassMap(classes: string | undefined): CssClassMap {
return map;
}
export function openURL(url: string, ev: Event, direction = RouterDirection.Forward) {
export function openURL(url: string, ev: Event, goBack = false) {
if (url && url[0] !== '#' && url.indexOf('://') === -1) {
const router = document.querySelector('ion-router');
if (router) {
ev && ev.preventDefault();
return router.componentOnReady().then(() => router.push(url, direction));
return router.componentOnReady().then(() => router.push(url, goBack ? -1 : 1));
}
}
return Promise.resolve();
}