import { Component } from '@angular/core';
import { NavController } from '@ionic/angular';
import { Router } from '@angular/router'; 

@Component({
  selector: 'app-tab1',
  templateUrl: 'tab1.page.html',
  styleUrls: ['tab1.page.scss'],
  standalone: false,
})
export class Tab1Page {

  constructor(
    private navCtrl:NavController,
    private router: Router
  ) {}
  goBridType(bridtype?:string){
    this.navCtrl.navigateForward(["tabs","tab1","page-bridtype"])
  }
  goWay(way?:string){
    this.navCtrl.navigateForward(["tabs","tab1","way"])
  }
  goNeighborhood(neighborhood?:string){
    this.navCtrl.navigateForward(["tabs","tab1","neighborhood"])
  }
  navigateToDetail() { // 定义一个方法用于导航到详情页面
    if (this.router.url !== '/detail') { // 检查当前 URL 是否不是目标页面
      this.router.navigateByUrl('/detail').then(() => { // 如果不是，则导航到详情页面
        console.log('Navigation completed.'); // 导航完成后打印日志
      }).catch(error => { // 捕获并处理可能发生的错误
        console.error('Navigation failed:', error); // 打印错误信息
      });
    } else { // 如果已经是目标页面
      console.warn('Already on the detail page, no need to navigate.'); // 打印警告信息
    }
  }

}
