📌  相关文章
📜  获取当前 url 角度 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:54.939000             🧑  作者: Mango

代码示例1
import { Component } from '@angular/core';
import { Router } from '@angular/router';

@Component({
    template: 'The href is: {{href}}'
    /*
    Other component settings
    */
})
export class Component {
    public href: string = "";

    constructor(private router: Router) {}

    ngOnInit() {
        this.href = this.router.url;
        console.log(this.router.url);
    }
}