📜  获取页面链接角度 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:34.478000             🧑  作者: 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);
    }
}