我正在Angular做我的第一个项目,我不知道该怎么做,我一直在搜索,但是我没有找到我想要的东西。
下一个结构。 主页->教程页面->登录页面
当您进入LoginPage并提供虚拟的后退或后退按钮时,该按钮实际上显示在左侧上方,我要返回的是HomePage。我一直在尝试不同的方法,但对我没有任何帮助,我的问题是,我不知道在按下时如何进行事件调用。谢谢
我的登录名
import { Component, OnInit } from '@angular/core';
import { IonicPage, NavController, NavParams, Platform } from 'ionic-angular';
@IonicPage()
@Component({
selector: 'page-login',
templateUrl: 'login.html',
})
export class LoginPage implements OnInit {
constructor(public navCtrl: NavController, public navParams: NavParams, private platform: Platform) {
}
ngOnInit() {
this.platform.backButton.subscribe(() => {
this.navCtrl.popToRoot();
});
}
goToSignUp() {
let id = this.idRecibido;
this.navCtrl.push("SignupPage", {id});
}
}
我还需要它与屏幕上的虚拟按钮配合使用
答案 0 :(得分:1)
您需要注入Platform
服务并订阅其backButton
这样的Observable:
import { Component, OnInit } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
@IonicPage()
@Component({
selector: 'page-login',
templateUrl: 'login.html',
})
export class LoginPage implements OnInit {
constructor(public navCtrl: NavController, public navParams: NavParams, private platform: Platform) {
}
ngOnInit() {
this.platform.backButton.subscribe(() => {
// Physical button pressed
});
}
goToSignUp() {
this.navCtrl.push("SignupPage");
}
}
答案 1 :(得分:0)
我的问题的完美解决方案是这个。
def merge(l1, l2):
first = ListNode(0)
# 'here' is where we link in the nodes.
here = first
while l1 and l2:
# Pick the next node from the inputs.
# Note that this has the same effect as assigning
# to 'first.next' on the first iteration, when 'first' and 'here'
# refer to the same object.
if l1.val < l2.val:
here.next = l1
else:
here.next = l2
# Move along to the last node we picked.
here = here.next
# Grab the rest.
if l1:
here.next = l1
else:
here.next = l2
return first.next