Is there a way to subscribe to an Observable
which is an @Input
?
For example:
export class MyComponent implements OnInit {
@Inp
You should implement OnChanges
and subscribe to the input when it changes.
export class MyComponent implements OnChanges {
@Input() results: Observable;
constructor() { }
ngOnChanges(changes){
if(changes["results"] && this.results){
this.results.subscribe(value => ...);
}
}
}
This will allow you to subscribe to the Observable once it is available and re-subscribe to it anytime that the Observable reference changes. You may need to consider unsubscribing from old instance depending on your use-case.