export class ListPeopleComponent implements OnInit {
@Input()
member:FullModel
search='';
constructor(private peopleService:PeopleService) { }
ngOnInit() {
this.peopleService.getPeople().subscribe(data =>
{
this.member=data;
console.log(this.member)
});
}
export class FullModel {
constructor(
public firstName: string,
public lastName: string,
public avatar: string,
public company: string,
public title: string,
public email: string,
public phone: string,
public street: string,
public city: string,
public zipCode: string,
public country: string,
public id?: number
) {
}
}
<h1>{{member.firstNam}}</h1>
class FullModel {
constructor(
public firstName: string,
public lastName: string,
public avatar: string,
public company: string,
public title: string,
public email: string,
public phone: string,
public street: string,
public city: string,
public zipCode: string,
public country: string,
public id?: number
) {
Реализовал пока что так!
Но я подправил правда JSON файл!
В отдельности каждый атрибут в консоль выводится! но при записи в member выкидует ошибку:
ERROR TypeError: Cannot set property 'firstName' of undefined
at SafeSubscriber._next (list-people.component.ts:25)
at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:195)
at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:133)
at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:77)
at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:41)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
at FilterSubscriber.push../node_modules/rxjs/_esm5/internal/operators/filter.js.FilterSubscriber._next (filter.js:38)
at FilterSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber.notifyNext (mergeMap.js:79)
Подскажите на что обратить внимание?
Спасибо