«TypeError.parent.context.car.getBrands не является функцией»: s

Обслуживание:

@Injectable()
export class Service {

    constructor(private http: Http) { }

    getCars(){
        return this.http.get...       
    }

    getById(id: string) {
        return this.http.get...       
    }    
}

Класс автомобиля:

export class Car {

    private brands: Array<Brand>;

    constructor(public id: string, public name: string) {
        this.brands = new Array<Brand>();
    }

    public getBrands(): Array<Brand> {
        return this.brands;
    }
    //some other methods.
}

Тогда у меня есть класс Brand (объект) с его собственными атрибутами и методами, и так далее, и так далее ...

car.list.component:

@Component({
    selector: 'car-list',
    template: `
    //some more code here
    <table>
        <tr *ngFor="let car of cars" >
        <td>{{car.name}}</td>
        <td><button (click)="goToDetail(car)">Detail</button></td>
        </tr>
    </table>
  `,
})


export class ListComponent implements OnActivate {
    id: string
    name: string;
    cars: Array<Car>

    constructor(public _service: Service, public _router: Router) {   }

    routerOnActivate(): void {
        this._service.getCars()
            .subscribe(cars => this.cars = cars);
    }
 }

И тогда проблема, car.detail.component:

@Component({
    selector: 'car-detail',
    template: `  
    <h1>Car: {{car?.name}}</h1>
    <hr>
    <div *ngFor="let brand of car?.getBrands(); let i=index">  
        <h2>Brand {{i+1}}</h2>
    </div>   

`,
})

export class DetailComponent implements OnActivate {

    @Input() car: Car;

    constructor(public _service: Service, public _router: Router) {    }

    routerOnActivate(curr: RouteSegment): void {
        let id = curr.getParam('id');
        this._service.getById(id)
            .subscribe(car => {
                this.car = car;
            });
    }
    //some other methods
}

При звонкеcar.getBrands() это дает ошибку:TypeError: self.parent.context.car?.getBrands is not a function

Ответы на вопрос(1)

Ваш ответ на вопрос