Use a service to save the category. And then you can use the same service to get the categoryType whenever you want it.
import { Injectable } from '@angular/core';
@Injectable()
export class AppMessageQueuService {
categoryType: string;
constructor() {
}
saveCateogry(cat:any){
this.categoryType= cat;
}
retrieveCategory(){
return this.categoryType;
}
}
Then you can inject this Service into both the components and save it from the first component like,
this.appMsgService.saveCateogry(yourcategory);
then retrieve in the second component as,
this.appMsgService.retrieveCategory();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…