I\'m trying to get a button click in one component to put focus on an element on another component. (Frankly, I don\'t understand why this must be so complex, but I have not bee
First of all, use a BehaviorSubject
instead of EventEmitter
. Change the declaration of skipCliekd
to the following:
skipClicked: BehaviorSubject = new BehaviorSubject(false);
Then, you need to broadcast the new value using next()
method as following:
this.skipClicked.next (true);
Also, change your subscription to:
this.skipToContent.skipClicked.subscribe( value => {
if (value === true) {
console.log("!");
// should put focus() on input
}
});