How to list / output all routes in @Routes in my Angular2 App

Here is a better version which will list all possible routes (fixed according to comments):

import { Router, Route } from "@angular/router";

constructor(private router: Router) { }

ngOnInit() {
  this.printpath('', this.router.config);
}

printpath(parent: String, config: Route[]) {
  for (let i = 0; i < config.length; i++) {
    const route = config[i];
    console.log(parent + "https://stackoverflow.com/" + route.path);
    if (route.children) {
      const currentPath = route.path ? parent + "https://stackoverflow.com/" + route.path : parent;
      this.printpath(currentPath, route.children);
    }
  }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)