I have 2 components. Component A and B. Component B has a value that I am trying to rereive in component A. Component B lies in a different folder to A. How can I send the value to A without using something like localStorage.
Here is my code for context.
Compononent B
@Input() offerExpiry: any;
async ngOnInit() {
this._loader.start();
if (this._exploreService.offer) {
...
} else {
const offer = await this._exploreService.getOfferDetails();
//value I need is 'this.offerExpiry'
this.offerExpiry = offer.expiryDate;
}
this._loader.stop();
}
Compononent A
import { Component, Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'app-offer-subheader',
templateUrl: './offer-subheader.component.html',
styleUrls: ['./offer-subheader.component.scss']
})
export class OfferSubheaderComponent {
@Input() title: string;
@Input() active: string;
@Output() back = new EventEmitter();
@Output() offerExpiry: any;
onBack() {
this.back.emit();
}
}
I am trying to use Input, Output but am not having any success