zoukankan      html  css  js  c++  java
  • Angular入门(四) Router 替换当前页面

    1.在 xx.html 中直接 写标签
          <a [routerLink]="['/home']">home</a>
     
    2.在 xx.html 中 触发click事件
      <button class="btn btn-primary" (click)="Login()">Submit</button>
       在xx.ts中 
           引入路由
               import { Route, Router, ActivatedRoute, Params } from '@angular/router';
          export 注入
      constructor(private route: ActivatedRoute, private router: Router) { }
          export 写 Login()函数
            Login(){

      this.router.navigate(['../home'],{relativeTo:this.route});//跳转到定义好的home 页面
    }

  • 相关阅读:
    接口类和抽象类
    生成器和迭代器
    装饰器
    KMP算法(java,c++)
    java EE
    XML
    SQL语法
    单元测试
    JDBC
    SpringCloud
  • 原文地址:https://www.cnblogs.com/zhuzy/p/8033200.html
Copyright © 2011-2022 走看看