I want to use Event emitter and subscribe in parent component.
This is my Service Code
@Injectable()
export class RecipeService{
    recipeselected= new EventEmitter<string>() ;
}
This is code, where I have used, event Emitter.
The function onselected is working
@Component({
  selector: 'app-receipie-item',
  templateUrl: './receipie-item.component.html',
  styleUrls: ['./receipie-item.component.css'],
  providers:[RecipeService]
})
export class ReceipieItemComponent implements OnInit {
  @Input() recipe:ReceipieModel ;//custom property
 
  constructor(private recipeservice:RecipeService) { }
  ngOnInit(): void {
  }
  onselected(){
    this.recipeservice.recipeselected.emit("hello");
    // console.log('hello');
  }  
}
This is code, where I have used, subscribe to event.
The problem is it is not working in subscribe.
@Component({
  selector: 'app-receipies',
  templateUrl: './receipies.component.html',
  styleUrls: ['./receipies.component.css'],
  providers:[RecipeService]
})
export class ReceipiesComponent implements OnInit {
  selectedrecipe:ReceipieModel;
  constructor(private recipeservice:RecipeService) { 
  }
  ngOnInit() {
    this.recipeservice.recipeselected.subscribe(
      recipe=>{ 
        console.log(recipe);
      }
    );
  }
  
}
 
     
    