简体   繁体   English

如何将数据从 angular 服务传递到外部 JS 库?

[英]How to pass data from an angular service to an external JS lib?

In the angular project I have a service that makes call into server to get login in and get back a bearer TOKEN that will be used to call to web services.在 angular 项目中,我有一项服务调用服务器以登录并取回将用于调用 web 服务的不记名令牌。

In fact, I'm using external JavaScript lib (piwik.js), I made some change on the lib (adding new methods the make calls to some api on order servers using that TOKEN).事实上,我使用的是外部 JavaScript 库 (piwik.js),我对库做了一些更改(添加了新方法,使用该令牌对订单服务器上的某些 api 进行调用)。

What I did not figure out here, is how to pass that TOKEN from the angular service to this external JS lib?我在这里没有弄清楚的是,如何将该令牌从 angular 服务传递到这个外部 JS 库?

any help is much appreciated.任何帮助深表感谢。

if that js library gives a mechanism to provide data to it, it doesn't matter whether you provide it from service of component.如果那个 js 库提供了一种向它提供数据的机制,那么你是否从组件的服务中提供它并不重要。 please figure out how that js library expects the data.请弄清楚那个js库是如何期望数据的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM