I don’t know how to connect telegram to angular. In the HTML file I do this –
<script src="./assets/telegram-web-app.js"></script>
But I don’t know what to do in the component to call the function I need.
https://core.telegram.org/bots/webapps#initializing-mini-apps
I searched for a solution on this site but couldn’t find it.
2
Answers
First, add it to your angular.json file:
Then in your component, declare a var with the same name as a telegram JS export. This tells angular what to look for in the JS (read more):
And use it in your component like:
If you have issues, try
"allowJs": true
within"compilerOptions"
in tsconfig.jsonSee these posts for more on how to access functions from a javascript file:
Including JS in Angular (recommended approach)
Including with a <script> tag
pleae use this for convenient https://github.com/zakarliuka/ng-telegram-webapp.