我试图获取HTTP帧的URL参数(" GET http://www.quatuoradbd.com/Reception?ID=00-80-00-00-00-00-d5-ef&Voltage=8 HTTP1.1主机:www.quatuoradbd.com")
为了测试,我使用了Fiddler软件。 所以我发送这个框架:(https://i.stack.imgur.com/T6MTA.png)
然后我得到这个回复:(https://i.stack.imgur.com/XXAIa.png)这是我的Angular网站的index.html以及balise之间的许多捆绑,而我想访问接收路线而不是index.html
此外,我收到的结果表明代码200的一切正常:(https://i.stack.imgur.com/vrdZP.png)
但是,我不明白为什么我的框架没有到达目的地(/接收),这样我就可以获得我的URL参数,即ID和电压。
要获取网址的参数,我的代码如下所示,因为当我直接将其写入chrome" http://www.quatuoradbd.com/Reception?ID=00-80-00-00-00-00-d5-ef&Voltage=8" (见图:https://i.stack.imgur.com/osInH.png),我的参数保存到我的数据库中:
this.activatedRoute.queryParamMap.subscribe((params: Params) => {
console.log(params);
this.device_id = params.get('ID');
this.Voltage = params.get('Voltage');
console.log(this.device_id);
console.log(this.Voltage);
});
答案 0 :(得分:0)
我认为我的接待路线很好吗?
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AppComponent } from './app.component';
import { AccueilComponent } from './accueil/accueil.component';
import { MenuComponent } from './menu/menu.component';
import { InconnuComponent } from './inconnu/inconnu.component';
import { ClientsComponent } from './clients/clients.component';
import { ProjetsComponent } from './projets/projets.component';
import { HistoireComponent } from './histoire/histoire.component';
import { InscriptionComponent } from './inscription/inscription.component';
import { IdentificationComponent } from './identification/identification.component';
import { ConfirmationCompteComponent } from './confirmation-compte/confirmation-compte.component';
import { MapComponent } from './map/map.component';
import { GraphiquesComponent } from './graphiques/graphiques.component';
import { ReceptionComponent } from './reception/reception.component';
const routes: Routes = [
{ path: '', redirectTo: '/Accueil', pathMatch: 'full' },
{ path: 'ConfirmationCompte/:email', component: ConfirmationCompteComponent },
{ path: 'Graphiques/:id', component: GraphiquesComponent },
{ path: 'Accueil', component: AccueilComponent },
{ path: 'Projets', component: ProjetsComponent },
{ path: 'Clients', component: ClientsComponent },
{ path: 'Histoire', component: HistoireComponent },
{ path: 'Inscription', component: InscriptionComponent },
{ path: 'Identification', component: IdentificationComponent },
{ path: 'Reception', component: ReceptionComponent },
{ path: 'Map', component: MapComponent },
{ path: '**', component: InconnuComponent }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }