So, this is a pretty abstract example, but let me take the following definitions of models and services:
Model / Object Definition - car.ts
...
export class Car{
color: string;
wheels: number;
oilChangeDate: Date;
tyreChangeDate: Date;
...
}
Service - car.service.ts
@Injectable()
export class CarService{
currentCar: Car;
constructor(http: Http){
...
}
...
serviceCurrentVehicle(){
currentCar.oilChangeDate = new Date();
currentCar.tyreChangeDate = new Date();
}
}
Questions
- Is it against Angular 2/4 style / design guidelines to move the logic behind serviceCurrentVehicle into a model definition? Why?
- Is it against the Angular 2/4 style / design guide as a whole to have logic tied to model definitions? And if not, how can I access the service while saving the constructor of the object? (i.e. without dependency injection)
I reviewed posts similar to before posting this question.
EDIT:
OAuth , , , () HTTP- () - /.