I'm completely new for angularjs2 platform. while i'm implementing the get method so I can get the product.From WebApi i'm getting the Json like below:
{"PersonalInfolistModel":
[{
"EmployeeCode":"1116",
"EmployeeName":"B Rama Krishna Reddy",
"EmployeeDesignation":"SCIENTIST 'E'",
"Salary":"50000"
}]{
"Address":[{
"Address1":"1116",
"Address2":"B Rama Krishna Reddy",
"Address3":"SCIENTIST 'E'"
}]
}
How can we import this service in Angular and show in HTML page?
What I have tried:
i tried like given below
my service
import { Injectable } from '@angular/core';
import { IEmployeePersonalInformation } from './PersonalInforamtion';
import { Observable } from 'rxjs/observable';
import { Http, Response } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class EmployeeService {
constructor(private _http: Http) { }
getEmployees(): Observable<IEmployeePersonalInformation> {
return this._http.get("http://localhost:4185/api/PersonalInformation/1116")
.map((response: Response) => <IEmployeePersonalInformation>response.json())
}
}
my component
import { Component, Input, OnInit } from '@angular/core';
import { IEmployeePersonalInformation } from './PersonalInforamtion';
import { EmployeeService } from './PersonalInformationService';
@Component({
selector: 'list-employee',
templateUrl: 'app/PersonalInformation/PersonalInformation.component.html',
styleUrls:['app/PersonalInformation/PersonalInformation.css'],
providers: [EmployeeService]
})
export class EmployeeListComponent implements OnInit {
employees: IEmployeePersonalInformation;
constructor(private _employeeService: EmployeeService) { }
ngOnInit() {
this._employeeService.getEmployees()
.subscribe((employeeData) => this.employees = employeeData);
}
}
if i have single json single array list then the code is working but if i have multiple json arrays like
PersonalInfolistModel
and
Address
code not working