如何插入angularjs代码?

How to insert angular js code?

我实际上是在为舞台做一个应用程序,它必须是响应式设计。所以它必须在手机、电脑和平板电脑上工作。对于这个应用程序,我需要使用 google api 地点自动完成功能。问题是它在移动设备上不起作用,无论是 iOS 还是 android... 在另一个论坛上我发现了一段代码,如下所示,应该可以解决这个问题:

.directive('disableTap', function($timeout) {
  return {
    link: function() {
      $timeout(function() {
        // Find google places div
        _.findIndex(angular.element(document.querySelectorAll('.pac-container')), function(container) {
          // disable ionic data tab
          container.setAttribute('data-tap-disabled', 'true');
          // leave input field if google-address-entry is selected
          container.onclick = function() {
            document.getElementById('autocomplete').blur();
          };
        });
      },500);
    }
  };
});

问题是我从来没有用过 Angular JS,我现在也没有时间去学习它,也许在我用完这个应用程序之后......功能应该让它在移动设备上运行,但我不知道如何使用它。你们能帮我解释一下如何在我的项目中插入这段代码以及如何使用它吗?我真的很需要帮助,我将不胜感激。顺便说一下,我不是英语母语所以如果你不明白我的 post 中的某些内容,请告诉我,我会尽量说得更好 ^-^

希望你能帮到我,谢谢:)

这在jQuery中应该是一样的,但是你得自己去适配。您还需要 underscore.js 库。希望这有帮助。

window.setTimeout(function() {
    // Find google places div
    _.findIndex($(document.querySelectorAll('.pac-container')), function(container) {
      // disable ionic data tab
      container.setAttribute('data-tap-disabled', 'true');
      // leave input field if google-address-entry is selected
      container.onclick = function() {
        $('#autocomplete').blur();
      };
    });
  },500);