Is it somehow possible to call a function coded in a Angular 9 component from jQuery?
I have an Angular 9 application where I have made it possible to include some small plug-ins written in jQuery. Now I want to make some simple function available from the Angular 9 app to the jQuery plugins.
E.g. showing a confirm modal (to make it easy to use the confirm modal used in the main app).
Then I need to call the Angular function with parameters (text to show in the modal) and also get a response when the user has confirmed.
Example of some of the Angular component that loads the jQuery plug-in into the markup, off a method for the jQuery plug-in:
@Component({
selector: 'ov-plugin-loader',
templateUrl: './plugin-loader.component.html',
styleUrls: ['./plugin-loader.component.scss'],
})
export class PluginLoaderComponent implements OnDestroy {
public readonly head = document.getElementsByTagName('head')[0];
public htmlString: SafeHtml;
constructor(....) { }
public callMeFromJquery (title: string, message: string): Observable<any> {
return ...
}
}
Then I would like to call that function from my jQuery code:
class MyJQueryPlugin {
doSomething() {
[call callMeFromJquery('header','content')]
}
}