-
阿波罗的战车
在Angular8中使用PlatformLocation类,此类保存url链接信息,如基地址,端口号等。使用如下:constructor(private platformLocation: PlatformLocation) {}ngOnInit() {console.log(this.platformLocation.href);//href属性即是当前url}
-
慕桂英3389331
import { Component, OnInit, Inject } from '@angular/core';import {ActivatedRoute, Params} from '@angular/router';@Component({selector: 'demo',template: `<div></div>`})export class DemoComponent implements OnInit {constructor(@Inject(ActivatedRoute) private router: ActivatedRoute) { }ngOnInit() {this.router.params.subscribe((params: Params) => {// params});}}
-
慕码人8056858
rootScope.$on('$stateChangeSuccess', function (ev, to, toParams, from, fromParams) {$rootScope.previousState = from;$rootScope.previousParams = fromParams;});
-
慕桂英546537
import { Component, OnInit, Inject } from '@angular/core';import {ActivatedRoute, Params} from '@angular/router';@Component({selector: 'demo',template: `<div></div>`})export class DemoComponent implements OnInit {constructor(@Inject(ActivatedRoute) private router: ActivatedRoute) { }ngOnInit() {this.router.params.subscribe((params: Params) => {// params});}