cherry
August 18, 2017, 3:15am
#1
Is there a finished module already if i swipe right or left that it performs a navPop ?
Or do i have to programm it by myself ?
Like this quick example:
swipeEvent($e) {
if ($e.deltaX <= 130) {
document.getElementById("backbutton").click();
};
}
<div id="backbutton" (swipe)='swipeEvent($event)' ion-button navPop>
Thanks for any answers.
cherry
August 21, 2017, 6:11am
#2
Does noone has an answer ?
MattE
August 21, 2017, 7:13am
#3
Can’t you just use the pop() method of the NavController?
this.navCtrl.pop();
cherry
August 21, 2017, 8:06am
#4
navPop works already as mentoined. But what i wanna do is if i swipe to the left that it performs a navPop and i just wanted to know if i have to code it by myself OR if there is a finished module for that already.
MattE
August 21, 2017, 8:18am
#5
cherry
August 21, 2017, 9:03am
#6
Thanks for your answer! I came to this doc.
DOC
I am using this code right now.
ngAfterViewInit() {
this.navCtrl.canGoBack();
console.log(this.navCtrl.canSwipeBack());
}
What happens i push to this Page and the navPop button appears and works. But it still returns a false for the SwipeBack.
Same with this instance member
canSwipeBack()
Do you know why this could be ?
I found this perhaps it is useful for you.
https://docs.angularjs.org/api/ngTouch/directive/ngSwipeRight
I woud add it to the contant tag and call a function inside.
<content ng-swipe-right="myPopFunciton()">
No Idea if this will work!? Try it
cherry
August 21, 2017, 10:20am
#8
I think the swipe function already works the only problem is that my application thinks that it can’t pop but i clearly can pop.
But thanks anyway.
Ahh ok, your swipe function work and you have tried navCtr.pop() right?
How do you open/call this page?
cherry
August 21, 2017, 10:50am
#10
navCtrl.pop()
also works.
Like I said the only problem i have right now is that
this.navCtrl.canSwipeBack();
gives me a false instead of a true and that kinda confuses me because it should give me a true since the page is able to pop.
The rest I can figure out for myself then .
Ok, but have you opened the actual page with navCtrl.push() or this navCtr.setRoot()
cherry
August 21, 2017, 10:54am
#12
Im pushing to the page like that.
TS
export class MyClass {
goToPopPage: any;
}
constructor(){
this.goToPopPage = PopPage;
}
HTML
[navPush]="goToPopPage"
Could that be the problem ?
I’m a beginner in ionic and angular and i never used [navPush]
I normally use
HTML
(click)="goToMyPage()"
TS
funciton goToMyPage(){
this.navCtrl.push(PopPage) // import PopPage or
this.navCtrl.push("PopPage") // lazy loading
}
cherry
August 21, 2017, 11:01am
#14
Yea i don’t need an extra method for it so I sticked to this code i wrote. Ill try it out with a method and post my results.
cherry
August 21, 2017, 11:07am
#15
Still gives me a false . I gues ill have to write a code for the function by myself if that won’t work.