1

I have a Webprojekt with FireBaseCloudMessaging running. Now i have to call a Method in a Typescript File to reload the Messages on Notification. Is this Possible?

HTML Part (index.html)

<script src="https://www.gstatic.com/firebasejs/4.3.0/firebase.js"></script>
<script>
    messaging.onMessage(function(payload) {
        console.log("Message received. ", payload);
        // ChatDialog.reloadMessages(); <-- Here i have to call the Typescript Method
    });
</script>

ChatDialog.ts

//This is the Method i have to call!
    reloadMessages(){
        this.messages.removeAll();
        localStorage.clear();
        ChatFunctions.getMessages(this, this.partner_id);
    }
4
  • How are you compiling your TS code? Do you use modules? Post your tsconfig.json? Commented Oct 6, 2017 at 8:29
  • Iam using NPM and Bower! Iam compiling my Typescript whit grunt! HTML to Typescript is handled whit Knockout and Typescript to HTML via JQuery and Ajax Commented Oct 6, 2017 at 8:37
  • Typescript is compiled to JS, so it's definitely possible – just like calling any method in JS. This might help you to find your way around: stackoverflow.com/questions/26427722/… Commented Oct 6, 2017 at 8:46
  • When iam calling it new ChatDialog().reloadMessages() it throws an error: Error: You cannot apply bindings multiple times to the same element.. Commented Oct 6, 2017 at 8:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.