Ramco Ramco

Ramco Ramco

  • 455
  • 3k
  • 423k

No data is returned

May 25 2024 6:26 AM

Hi

  I have below code . API has records but it shows no data

export class EmployeeService {

  constructor(private htpClient: HtpClient) { }

  getallEmployee(): Observable<any> {
      return this.htpClient.get('onlinetestapi.gerasim.in/api/TeamSync/GetAllEmployee');
  }
import { Component,ViewChild,ElementRef,OnInit } from '@angular/core';
import { EmployeeService } from '../../service/employee.service';
import { FormBuilder,FormsModule, ReactiveFormsModule, FormGroup, FormControl, Validators } from '@angular/forms';
import { CommonModule } from '@angular/common';

@Component({
  selector: 'app-employee',
  standalone: true,
  imports: [CommonModule, FormsModule,ReactiveFormsModule],
  templateUrl: './employee.component.html',
  styleUrl: './employee.component.css'
})
export class EmployeeComponent implements OnInit {
  @ViewChild('myModal') model : ElementRef | undefined;

  employeeArray: any[] = [];
  objEmployee: any = {
    "empId":0,
    "empName": "",
    "empContactNo": "",
    "empEmail": "",
    "addressLine1": "",
    "addressLine2": "",
    "pinCode":"",
    "city": "",
    "state": "",
    "bankName":"",
    "iFSC": "",
    "accountNo":"",
    "bankBranch":"",
    "salary":0
  }
  constructor(private empSrv:EmployeeService){}
  get f(){
    return this.form.controls;
  }
  
  ngOnInit():void{
    this.loadAllEmployee();
  }
  
  loadAllEmployee(){
    this.empSrv.getallEmployee().subscribe((res:any)=>{
      this.employeeArray = res.data;
    })
  }

Thanks


Answers (1)