Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

read parameters from url angular routes

// ...
import { ActivatedRoute } from '@angular/router';

@Component({ ... })
export class BookComponent implements OnInit {
  
  orderby: string;
  
  constructor(private route: ActivatedRoute) { }

  ngOnInit() {
    this.route.queryParams
      .subscribe(params => {
        console.log(params); // { orderby: "price" }
        this.orderby = params.orderby;
        console.log(this.orderby); // price
      }
    );
  }
}
Source by www.angularjswiki.com #
 
PREVIOUS NEXT
Tagged: #read #parameters #url #angular #routes
ADD COMMENT
Topic
Name
8+4 =