【问题标题】:How to insert angular js code?如何插入角度js代码?
【发布时间】:2015-04-30 08:35:30
【问题描述】:

我实际上是在为一个舞台做一个应用程序,它必须是响应式设计。所以它必须在手机、电脑和平板电脑上工作。对于这个应用程序,我需要使用 google api Place Autocomplete。问题在于它不能在移动设备上运行,无论是 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,我现在没有时间学习它,也许在我完成应用程序之后......而且这个功能应该可以实现可以在手机上使用,但我不知道如何使用它。你们能帮我解释一下如何在我的项目中插入此代码以及如何使用它吗?我真的很需要帮助,我们将不胜感激。顺便说一句,我不是英语本地人,所以如果你没有理解我帖子中的某些内容,请告诉我,我会尽量说得更好^-^

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

【问题讨论】:

    标签: angularjs google-api


    【解决方案1】:

    这在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);
    

    【讨论】:

    • 谢谢你的帮助,我没有意识到它可以这么容易地在 jquery 中转换......我现在可以毫无问题地找到解决方案:)。我希望它现在可以工作!再次感谢
    猜你喜欢
    • 1970-01-01
    • 2015-11-20
    • 1970-01-01
    • 1970-01-01
    • 2019-06-05
    • 1970-01-01
    • 2017-11-27
    • 2021-04-12
    • 1970-01-01
    相关资源
    最近更新 更多