Raju Kandikonda

Raju Kandikonda

  • NA
  • 26
  • 9.4k

Angular 7 querystring param getting 'undefind'

Apr 29 2019 11:44 AM
Hi All.
 
I am getting in querystring format undefind. what is the wrong in my code . I want to show user enter details. Please help me.
 
http://devweb-adept.transit.nyct.com:8089/RMS_WebService/api/Logins/CheckPassword?Id=[undefind]&Password=[undefind].
 
"login.service.ts"
  1. constructor(private http: HttpClient) { }  
  2.   
  3. getLoginById(AdeptUserID: string, Password: string): Observable<Login[]>{  
  4. debugger;  
  5. let params=new HttpParams().set('AdeptID', AdeptUserID).set('Password', Password);  
  6. console.log(params.toString());  
  7. return this.http.get<Login[]>(this.baseURL, {params});  
  8. }  
"locing.component.ts"
  1. constructor(  
  2. private loginService: LoginService,  
  3. private router:Router,  
  4. private route: ActivatedRoute, private formbuilder: FormBuilder)  
  5. {}  
  6. onFormSubmit() {  
  7. this.loading = true;  
  8. const client = this.clientForm.value;  
  9. this.getLogin(client);  
  10. this.clientForm.reset();  
  11. }  
  12. ngOnInit() {  
  13. debugger;  
  14. this.clientForm = this.formbuilder.group({  
  15. AdeptUserID: ['', [Validators.required]],  
  16. Password: ['', [Validators.required]]  
  17. });  
  18. }  
  19. getLogin(login :Login){  
  20. debugger;  
  21. this.loading = true;  
  22. this.loginService.getLoginById(this.clientForm.AdeptUserID,this.clientForm.Password).subscribe((response) => {  
  23. {this.Login=response;}  
  24. });  
  25. }  
"login.component.html"
  1. <div class="container">  
  2. <mat-card>  
  3. <mat-toolbar color="accent">  
  4. <div align="center" style="color:white;text-align:right;">  
  5. Login  
  6. </div>  
  7. </mat-toolbar>  
  8. <br>  
  9. <br>  
  10. <mat-card-content>  
  11. <form [formGroup]="clientForm"  
  12. (ngSubmit)="onFormSubmit(clientForm.value)">  
  13. <table>  
  14. <tr>  
  15. <td class="tbl1">  
  16. <mat-form-field class="demo-full-width">  
  17. <input formControlName="AdeptUserID" matTooltip="Enter login AdeptUserID" matInput placeholder="AdeptUserID">  
  18. </mat-form-field>  
  19. <mat-error>  
  20. <span *ngIf="!clientForm.get('AdeptUserID').value && clientForm.get('AdeptUserID').touched">  
  21. </span>  
  22. </mat-error>  
  23. </td>  
  24. </tr>  
  25.   
  26. <tr>  
  27. <td class="tbl1">  
  28. <mat-form-field class="demo-full-width">  
  29. <input formControlName="Password" matTooltip="Enter login Password" matInput placeholder="Password">  
  30. </mat-form-field>  
  31. <mat-error>  
  32. <span *ngIf="!clientForm.get('Password').value && clientForm.get('Password').touched">  
  33. </span>  
  34. </mat-error>  
  35. </td>  
  36. </tr>  
  37. </table>  
  38. <table>  
  39. <tr>  
  40. <td class="content-center">  
  41. <button type="submit" mat-raised-button color="accent" matTooltip="Click Submit Button" [disabled] = "!clientForm.valid">Login</button>  
  42. <button type="reset" mat-raised-button color="accent" matTooltip="Click Reset Button" (click) = "resetForm()">Reset</button>  
  43. </td>  
  44. </tr>  
  45. </table>  
  46. </form>  
  47. </mat-card-content>  
  48. </mat-card>  
  49. </div>  

Answers (2)