Home > Mobile >  Get array from key in URL
Get array from key in URL

Time:10-19

I got an Element like:

temp = new NewsElement('2', 'Überschrift', 'Inhalt', 'schoenesBild');
temp.addChapter('Kap1Überschrift', 'Kapitel1Inhalt');
temp.addChapter('Kap2Überschrift', 'Kapitel2Inhalt');
this.news[temp.key] = temp;

and I wanna get a Website to build from the url key:

localhost:4200/test?topic=2

The project is written with Angular.

CodePudding user response:

Fisrt get the query params in the constructor

topic: string;
constructor(private route: ActivatedRoute) {
    console.log('Called Constructor');
    this.route.queryParams.subscribe(params => {
        this.topic= params['topic'];
    });
}

and then use that

this.news[this.topic] = temp;

is that what you want?

  • Related