问题
I want to create service for Strophe.JS XMPP library in angular2 project. That service is responsible for Open and Close connection and include handler to receive message. I am able to do in .Net MVC project but i did not found a way to implement in Angular2 framework.
Thanks, Sanjeev
回答1:
First to install @types/strophe
npm install --save @types/strophe
Second to download Strophe library from Strophe Site
Then, You should put the framework inside /src/assets/
Then, You should add the script tag to the index.html before polyfills.js and main.js
Thus
<script src="assets/strophejs-1.2.14/strophe.js"></script>
Last,
you should put this declare statement before to use the strophe.
declare var Strophe: any;
It works for me!
I hope to help you.
Regards.
来源:https://stackoverflow.com/questions/43965906/strophe-xmpp-using-angular-2