javascript - AngularJS:不是函数类型错误

标签 javascript angularjs

我正在尝试使用 jQuery Geocomplete使用我的 AngularJS 应用程序。

我的 html 页面中有这个。

    <input id="destination-location-input" type="text" class="form-control"
     ng-model="destCtrl.destination" ng-change="destCtrl.locationChanged()" 
     data-geocomplete="street address" required/>

并在 Controller 中添加此代码。

var myElement = angular.element( document.querySelector('#destination-location-input'));    

myElement.geocomplete(
    {
      appendToParent: true,
      onChange: function(name, result) {
         var location = result.geometry.location;
      },
      onNoResult: function(name) {
         console.log("Could not find a result for " + name)
      }
    });

运行我的应用程序时,出现此错误。

TypeError: myElement.geocomplete is not a function

可能是什么问题?

最佳答案

确保在加载此插件之前将 Google Maps API 包含在 Places Library 中,如 here 所述

<script src="http://maps.googleapis.com/maps/api/js?libraries=places"></script>
<script src="jquery.geocomplete.js"></script>

关于javascript - AngularJS:不是函数类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49292853/

相关文章:

javascript - D3.js:带有文本和工具提示的 Clustered Force 布局

javascript - 如何显示长时间非 ajax 操作的繁忙指示器?

ios - 如何使用 Ionic Framework 在 ubuntu 中构建 ios 应用程序?

javascript - Chrome : Adding options to a select after the user has opened it

angularjs - 仅更改 ui.router 中状态更改的一种 View ?

javascript - JavaScript 和 DOM 究竟是如何工作的?

javascript - 用数组和循环简化一些jquery

javascript - 从 CSS 工具提示中获取文本

javascript - Angular-ui-grid 的 cellClass 错误

node.js - npm 错误!尝试安装 package.json 时,git dep 准备失败