欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

【Angular5】 返回前一页面 go back to previous page 返回上一页 有大用 有大大用


Angular4_ 返回上一页


最简单的实现方法。。。


<button (click)="goBack()" class="btn btn-outline-info" style="float:left;width:180px">Back</button>

goBack() {

    history.go(-1);

  }


如果想保留数据。可以选择路由复用


链接:点击打开链接


可能出现的错误:点击打开链接


来自  https://blog.csdn.net/qq_36279445/article/details/80235453






【Angular5】 返回前一页面 go back to previous page


import { Component, OnInit } from '@angular/core';
import { Router} from '@angular/router';
import { Location } from '@angular/common';

@Component({
  selector: 'app-notfound',
  templateUrl: './notfound.component.html',
  styleUrls: ['./notfound.component.scss']
})
export class NotfoundComponent implements OnInit {

  constructor(public _router: Router, private _location: Location) { }

  ngOnInit() {

  }

  goBack() {
    this._location.back();
  }
}
   
分类: Angular        

来自  https://www.cnblogs.com/liulei-cherry/p/10232126.html

普通分类: