в моем приложении Angular у меня есть компонент:
import { MakeService } from './../../services/make.service';
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-vehicle-form',
templateUrl: './vehicle-form.component.html',
styleUrls: ['./vehicle-form.component.css']
})
export class VehicleFormComponent implements OnInit {
makes: any[];
vehicle = {};
constructor(private makeService: MakeService) { }
ngOnInit() {
this.makeService.getMakes().subscribe(makes => { this.makes = makes
console.log("MAKES", this.makes);
});
}
onMakeChange(){
console.log("VEHICLE", this.vehicle);
}
}
но в свойстве "делает" у меня ошибка. Я не знаю, что с этим делать...

Решение проблемы
Просто перейдите в tsconfig.json и установите
"strictPropertyInitialization": false
чтобы избавиться от ошибки компиляции.
В противном случае вам нужно инициализировать все ваши переменные, что немного раздражает.
Комментариев нет:
Отправить комментарий