javascript - openweathermap API 到 Angular ES6

标签 javascript angularjs ecmascript-6

我想在现有项目中实现 openweathermaps api,但在添加一些依赖项时遇到问题。

当前项目正在使用 ES6(我认为它是 Angular 的 1.5.x 版本),并且我已通过 Bower Angular-openweathermap-api-factory 模块安装。

我收到此错误:ReferenceError:openweathermapFactory 未定义 我猜它与“将 jtt_openweathermap 添加到应用程序的模块依赖项”有关。因为我不知道如何将它添加到 ES6 项目中。

有什么帮助吗?

最佳答案

This tutorial似乎使用相同的 API。这是 reference implementation这似乎有效。

看看this file 。请注意,在第 1 行中,作者如何将库作为 jtt_openweathermap 导入到他的 Angular 模块中?具体的代码行如下所示:

angular.module('myApp', ['ui.router', 'ngGeolocation', 'ngProgress', 'ui.router.title', 'jtt_openweathermap', 'ngMap'])

你也需要这样做。我想你可能不会这样做。我也会看看这个controller code在这里并确保您的导入也得到正确处理。

关于javascript - openweathermap API 到 Angular ES6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45190983/

相关文章:

javascript - 查看在 javascript 中单击了哪个元素?

javascript - 与上下文无关的 JavaScript 测试框架

javascript - 如何使 href 与 ng-click 中的函数结果一起使用?

angularjs向图像添加不安全标签

javascript - 使用 ES6 "Cannot resolve symbol"语法时为 `import`

javascript - 导入与导入自的区别

javascript - 右键单击并选择 "open..."之一后替换上下文菜单中的 href 链接

javascript - Bootstrap - 模态 - 访问父对象的值

javascript - 加载更多数据 - ScrollTop 功能不起作用

html - 如何在angularjs中刷新html Canvas 指令