component 1
import { Component } from '@angular/core';
@Component({
selector: 'app-component1',
template:
`
<button (click)="submit()"></button>
`
})
export class Component {
constructor() {
}
someMethod(): void {
}
}
component 2
import { Component } from '@angular/core';
@Component({
selector: 'app-component2',
template:
`
<p>text</p>
`
})
export class Component2 {
constructor() {
}
}
i want to call the component 1 someMethod() from component 2
component 1 and component 2 haven't any parent/child relation.
is there any way to get the instant of component 1 in component 2
in java something like this
MyClass myClass = applicationContext.getBean("myClass");
is there any possible way like this in angular without BehaviorSubject
and EventEmitter
?