我应该如何使用Angular JS设置typeahead的使用?

时间:2015-04-11 04:56:41

标签: javascript jquery typeahead.js

我正在尝试使用 typeahead.js ,但我得到的只是Uncaught TypeError: undefined is not a function

我:

  • 在jQuery之后加载
  • 我的脚本中的任何地方都没有使用$(document).ready(...)
  • 使用Angular JS(即使我不认为这是一个问题)
  • 在整个角度内容之后加载jQuery
  • 确保所有脚本都存在且正在加载。

这就是我整个资源加载的样子(没有输出类型):

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="http://bootswatch.com/flatly/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.3/animate.min.css">
<link rel="stylesheet" type="text/css" href="css/rules.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.3.1/lodash.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular-cookies.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular-animate.min.js"></script>
<script type="text/javascript" src="js/angular/dependencies/checklist-model.js"></script>

<script type="text/javascript" src="js/jQuery/jquery.js"></script>  THIS NOT ANOTHER jQuery
<script type="text/javascript" src="js/functions.js"></script>

重要:

<script type="text/javascript" src="js/jQuery/jquery.js"></script>不是另一个jQuery,它只是一个可以做一些选择的函数。

我尝试加载(在所有这些sripts之后):

  • 加载捆绑包:

    <script type="text/javascript" src="js/dependencies/typeahead.bundle.min.js"></script>

  • 加载typeahead和bloodhound:

<script type="text/javascript" src="js/dependencies/typeahead.jquery.min.js"></script> <script type="text/javascript" src="js/dependencies/bloodhound.min.js"></script>

这些都不起作用,我找了issues on github,但没找到...... This is what I'm getting,以防万一,我正在使用Chrome的最新版本。

更新|发现问题

我发现是什么导致了它,但我无法理解或理解为什么以及如何解决它。

所以,jQuery/jquery.js,这不是另一个jQuery是使它全部失败的文件,看起来完全像这样:

function dojQuery () {

  $(".hover-resize").hover(

    function() { $(this).css("font-size","95px"); },
    function() { $(this).css("font-size","75px"); }
  );

  $('.dropdown-toggle').click(function() {
      var location = $(this).attr('href');
      window.location.href = location;
      return false;
  });

  $('#modifyItemModal').on('hidden.bs.modal', function () {
    $("#myOrderReview").modal('show');
  });

  $('#reviewConfirmationModal').on('hidden.bs.modal',function() {
    $("#orderReview").modal('show');
  });

  $('.supervisorModal').on('hidden.bs.modal',function() {
    $("#orderReview").modal('show');
  });

};

通过简单的调用dojQuery();声明的函数在Angular控制器中被调用一个不包括调用函数的fie使得它对tyepeahead一切都很好....最后我猜它是关于jquery冲突的东西但我无法理解修复。

0 个答案:

没有答案