How to return value from InAppBrowser to Ionic app

We are loading given URL in the inappbrowser from ionic app, which will load HTML form along with one hidden input field.

I am trying to get that hidden field value while tapping submit button using inappbrowser’s executeScript method as follow:

  browser.executeScript({
      code:
        "var result; document.getElementById('BtnSubmit').addEventListener('click', function(){" +
        "result = document.getElementById('myInput').value;});",
    });

In result variable, input value is fetched but need to return that from executeScript into ionic app context. Please let me know if any solution? Thanks in advance.