如何使用Ionic 2在欢迎页面部分中自动单击显示ng重复值?



如何使用Ionic 2动态在欢迎页面部分中显示ng重复第一个值时进行自动on click

  • 我正在开发Ionic 2中的应用程序。

  • 如果我登录到应用程序,它将直接进入欢迎页面,在此欢迎页面中显示一些 ng-repeat 值,如果我们单击任何一个值,它会重定向到身份验证值页面...

  • 我确切地在寻找的是,如果我登录到应用程序,它会直接进入欢迎页面,但是当我进入欢迎页面时,第一个 ng-repeat 值应该自动单击,它会重定向到验证值页面......

  • 第一步是我登录到应用程序,然后它重定向到欢迎页面,之后显示 ng-repeat 第一个值应该自动单击,需要重定向该值页面...

  • 如何在离子2中自动单击第一个ng重复值? 进入欢迎页面时...

  • 例如,看看这个 Plunker 如果我们首先进入这个 plunkertab1页面正在显示,那么open modal按钮可用,如果单击该open modal按钮,它将重定向到身份验证页面....但是我正在寻找在进入页面时tab1open modal按钮应该自动单击(或者)应该需要重定向模态页面....自动on click功能需要执行此过程,我已经尝试过但无法获得解决方案.....

  • 截至目前,在登录应用程序时,我直接进入欢迎页面,然后此欢迎页面中显示一些 ng-repeat 值,并且在单击第一个 ng-repeat 值时,它会重定向到身份验证页面,但我正在寻找自动单击第一个值,例如一种自动提交方法......

  • 例如:- 进入主页时,第一个ng重复值需要自动点击(或)需要重定向第一个ng重复值页面....

  • 是否有任何自动点击功能
  • 可用,我正在寻找自动点击值功能,

  • 如果有任何示例和解决方案,请提出建议并更新谢谢...

由于我不知道您的代码,因此您可以执行以下操作:

您可以使用 Ionic 2 或 Angular 2 页面生命周期事件在页面加载/加载时触发某些内容。如果您需要进一步的建议,请查看 NavController 生命周期文档。

由于单击只是调用函数的一种方式,因此还有其他方法可以做到这一点,例如,在javascript上,我们使用document.ready()函数在加载页面时执行某些操作。在 Ionic 2/Angular 2 中,我们也可以做到这一点。

您不会模拟单击,只需调用一个函数。

但是让我们做一些编码。您可以将其添加到您的主 .ts 文件中:

// AGAIN: since i don't know your code, i'll do something on my own.
import { ModalController } from 'ionic-angular';
export class HomePage {
myNgrepeatData: any[] = [];
constructor(public modCtrl: ModalController){}
ionViewWillLoad(){
// in this first lifeCycle you'll load all the data you need, this function fires when you'll load the page
// Here you'll get the data you'll display on the ngRepeat (on ionic 2 it's ngFor).
this.myNgrepeatData = SomethingToGetData();
}
ionViewDidLoad(){
// In this function - called when the view is finally loaded, you'll call your modal AND pass your first object property as an parameter.
// You'll declare a modal and pass these arguments:
// 1 - The page you want to show.
// 2 - Your object, or the first property first value, since you know you want this.
// 3 - Optional values for configuring your modal.
const modal = this.modalCtrl.create(ThePageToRedirect, this.myNgrepeatData[0], { enableBackdropDismiss: false });
// this is also opitional, if you want to do something when the modal is dismissed.
modal.onDidDismiss(data => {
// DO STUFF
});
// present it if not signed in
var signed: boolean;
signed = DoSignCodeYouNeedToDo();
if(signed){
// DO WHAT YOU WANT IF ALREADY SIGNED IN
} else {
modal.present();
}
// IF YOU NEED TO REDIRECT TO A PAGE USE NAVCONTROLLER LIKE THIS:
// this.navCtrl.push(PageYouWant, this.myNgrepeatData[0]);
}
}

如您所知,在您的模式中,您需要从ionic-angular导入ViewController以关闭页面。

如果您需要更多帮助,请询问。希望这对你:)有所帮助

最新更新