I have an ionic web application where I need to integrate third party javascript files. There are couple pf functions I have defined in javascript ( these defined in index.html.) . There are listeners added by the third party javascript which will trigger these methods whenever event happens.
in index.html
<script src="https://test.testservice.net/includes/test.min.js"></script>
<script>
function a (data){
//. I want to call ionic component method here
// TestPage.submitData
}
function b(){
}
</script>
That is still super vague. But, from what I gather, you are trying to call a method in a view “IonicPage controller” from your index where you are listening for events from a 3rd party library.
If this is this case, that is bad design. You should abstract out your API call so it can be called from both locations.
If you need additional help, you will need to provide actual code examples using proper code blocks.
@twestrick Thanks for your time. have updated my question. Pardon for my language.
Regarding integration, I do not much control on the thirdparty javascript file. I need to consume the data returned in method a and call my ionc app specific components to handle it.
I am not familiar with Angular (at least that is what your component looks like), but in general as I said, it is bad practice to do what you are trying to do. Why not abstract out the submitData logic into a service class that both your component and index can call?
When ionic service components gets initializes I’m calling a method defined in javascript ( defined in index.html) which will capture the reference of the service. Later in method a/b I’m calling the required service functions through reference.