2016-11-27 184 views
1

我怎樣才能得到PARAMS這樣:角2獲取路線PARAMS

mydomain.com/?token=MY_TOKEN&some=test 

我怎樣才能得到tokensome從URL到我的角2的組成部分? 我想:

this.route.params 
    .subscribe((params) => { 
     this.token = params['token']; 
     this.some = params['some']; 
    }); 
+0

...發生了什麼? – jonrsharpe

+0

可能重複的[如何從angular2查詢參數從url](http://stackoverflow.com/questions/35688084/how-get-query-params-from-url-in-angular2) – Fiddles

回答

0

這是查詢參數您正在尋找

this.route.queryParams 
.subscribe((params) => { 
    this.token = params['token']; 
    this.some = params['some']; 
});