Angular4_获取当前Url地址和获取Url传递的参数

import { Location } from '@angular/common';

console. log( location.pathname);

以上就是获取URL地址

获取参数:
import { ActivatedRoute } from '@angular/router';

constructor( @ Inject( DOCUMENT) private document : Document, private route : ActivatedRoute, private service : LoadOrdersService) { }

const loadTaskId : string | null = this. route. snapshot. paramMap. get( 'loadTaskId');

你可能感兴趣的:(Angular2.x)