“Angular Get URL Param” Kod odpowiedzi

Angular Get URL Param

constructor(private activatedRoute: ActivatedRoute) {
  this.activatedRoute.queryParams.subscribe(params => {
        let date = params['startdate'];
        console.log(date); // Print the parameter to the console. 
    });
}
GutoTrosla

Angular Get URL Params

import { ActivatedRoute } from "@angular/router";

//import ActivatedRoute in constructor()
private $route: ActivatedRoute

// in ngOnInit() call
//myvar is the variable where you want to store your param
this.$route.params.forEach(param =>
	this.myvar = param['whatever your param name is']
);
Victor Grk

Parametr URL kątowy

// example url: details?id=2

constructor(private activatedRoute: ActivatedRoute) {
  this.activatedRoute.queryParams.subscribe(params => {
        console.log(params); // Prints {id: "2"}
    });
}
Ham-Solo

w Angular, jak uzyskać adres URL routera bez parametrów zapytań

this.router.url.split('?')[0] 
Defeated Dotterel

Odpowiedzi podobne do “Angular Get URL Param”

Pytania podobne do “Angular Get URL Param”

Więcej pokrewnych odpowiedzi na “Angular Get URL Param” w TypeScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu