angularjs 怎样获取当前url

2024-11-09 00:33:01
推荐回答(3个)
回答1:

$location.absUrl();
http://www.tuicool.com/articles/ZzMr2qU

回答2:

var absUrl = $location.absUrl();
console.log(absUrl)

回答3:

import { Component, OnInit, Inject } from '@angular/core';
import {ActivatedRoute, Params} from '@angular/router';
@Component({
selector: 'demo',
template: `

乱激姿`
})
export class DemoComponent implements OnInit {
constructor(@Inject(ActivatedRoute) private router: ActivatedRoute) { }
ngOnInit() {
this.router.params.subscribe((params: Params) =>哗绝铅昌 {
// params
});
}