Answers for "typescript get query params from url"

0

get url params in typescript

import {Router, ActivatedRoute, Params} from '@angular/router';
import {OnInit, Component} from '@angular/core';

@Component({...})
export class MyComponent implements OnInit {

  constructor(private activatedRoute: ActivatedRoute) {}

  ngOnInit() {
    // Note: Below 'queryParams' can be replaced with 'params' depending on your requirements
    this.activatedRoute.queryParams.subscribe(params => {
        const userId = params['userId'];
        console.log(userId);
      });
  }

}
Posted by: Guest on September-02-2020

Code answers related to "typescript get query params from url"

Code answers related to "Javascript"

Browse Popular Code Answers by Language