I have been stuck for almost a week. Want to fetch URL parameters and send it to backend(Mongodb). Please help me. Every suggestions will be appreciated.
I am able to get URL params into HTML but want to show it in MongoDatabase. Sharing my code below
Contact.component.ts
import { Component, OnInit, NgModule, SimpleChanges, OnChanges, DoCheck, Input } from '@angular/core';
import { Feedback } from '../model/feedback';
import { AuthGuardService } from '../guards/auth-guard.service';
import { ActivatedRoute } from '@angular/router';
import { ApiService } from '../api.service';
@Component({
selector: 'app-contact',
templateUrl: './contact.component.html',
styleUrls: ['./contact.component.scss', './contact.component.mobile.scss']
})
export class ContactComponent implements OnInit {
//name of parameters to fetch
// @Input() authors: AuthorModel;
bannerid: string;
devicetype: string;
country: string;
constructor(private authGuardService: AuthGuardService,
private route: ActivatedRoute,
private apiService: ApiService) { }
ngOnInit(): void {
this.route.queryParams.subscribe(queryParam => {
this.bannerid = queryParam.bannerid;
this.devicetype = queryParam.devicetype;
this.country = queryParam.country;
console.log(queryParam);
})
}
ngOnChanges(changes: SimpleChanges): void {
console.log(changes);
}
feedModel = new Feedback('', '', '', '', '', '', '');
onSubmit(data): void {
// console.log(data);
// console.log(this.feedModel);
this.apiService.onSubmit(data);
this.authGuardService.feedBack(this.feedModel);
}
// queryParam(latest): void{
// console.log(latest);
// this.apiService.queryParam(this.bannerid);
// }
}