Does Angular 8 have an syntax change/upgrade for multiple instances of a service? Doing this will not work below, as they are still sharing the same service data,
I Saw an answer here, just curious if Angular 8 providers for different syntax,
Using multiple instances of the same service
export class ProductComponent implements OnInit {
@Input() propertyViewDto: PropertyViewDto2;
carMessage: any;
foodMessage: any;
public carData: arcData;
public foodData: FoodData;
constructor
(
private readonly carService: ProductService,
private readonly foodService: ProductService..
ngOnInit() {
this.carService.currentMessage.subscribe(currentMessage => {
this.carMessage = currentMessage;
this.carData= this.carMessage.value;
})
this.foodService.currentMessage.subscribe(currentMessage => {
this.foodMessage = currentMessage;
this.foodData= this.foodMessage.value;
})
Product Service:
export class ProductService{
private messageSource = new Subject();
currentMessage = this.messageSource.asObservable();
constructor() { }
changeMessage(currentMessage) {
this.messageSource.next(currentMessage);
}
}