Answers for "check current page router ionic"

1

get current url ionic 4

With pure JavaScript:

console.log(window.location.href);

Using Angular:

this.router.url

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);
    }
}
Posted by: Guest on May-29-2020

Code answers related to "check current page router ionic"

Browse Popular Code Answers by Language