我有一個元素,如:
temp = new NewsElement('2', 'überschrift', 'Inhalt', 'schoenesBild');
temp.addChapter('Kap1überschrift', 'Kapitel1Inhalt');
temp.addChapter('Kap2überschrift', 'Kapitel2Inhalt');
this.news[temp.key] = temp;
我想從 url 鍵建立一個網站:
本地主機:4200/test?topic=2
該專案是用 Angular 撰寫的。
uj5u.com熱心網友回復:
首先在建構式中獲取查詢引數
topic: string;
constructor(private route: ActivatedRoute) {
console.log('Called Constructor');
this.route.queryParams.subscribe(params => {
this.topic= params['topic'];
});
}
然后用那個
this.news[this.topic] = temp;
那是你要的嗎?
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/324812.html
下一篇:從動態嵌套陣列生成物件的平面陣列
