简体   繁体   English

angular.js控制器中的Bootstrap Tapdrop jQuery

[英]Bootstrap Tapdrop jQuery in angular.js controller

I saw Bootstrap Tapdrop library and it is perfect for dropdown in my responsive tabs. 我看到了Bootstrap Tapdrop库,它非常适合响应式选项卡中的下拉菜单。 My app works with angular.js, but add the bootstrap-tapdrop.js in my index.html . 我的应用程序可与angular.js一起使用,但是在我的index.html中添加bootstrap-tapdrop.js。

I want to call: 我想打电话给:

$('.nav-tabs').tabdrop({align:'left'});

into my angularjs app but nothing works. 进入我的angularjs应用程序,但没有任何效果。 However, when I call this from chrome console works ok. 但是,当我从chrome控制台调用此程序时,效果很好。

How can I add this sentence jQuery angular.js my driver? 我如何添加这句话jQuery angular.js我的驱动程序? is there anyway? 反正有吗 or..how can I use this library from angular.js? 或..如何从angular.js使用此库? I have sought similar things in angular but can not find. 我曾在角度寻求类似的东西,但找不到。

Thanks 谢谢

You have to create a directive in order to use jQuery plugins or whenever you want to attach client side behavior to elements using jQuery or any third party plugins. 您必须创建一个指令才能使用jQuery插件,或者每当您想要使用jQuery或任何第三方插件将客户端行为附加到元素时。

Try something like this. 尝试这样的事情。

angular.module('main')
  .directive('my-tabs-directive', [ function ($timeout, $sce) {
      return {
        restrict: 'E',
        link: function (scope, element, attrs) {
          //Write any plugin logic here
          element.tabdrop({align: 'left'});
        },
        templateUrl: 'passYourTemplateUrl'//You can also use inline template
      };
    }
  ]);

You can understand more about angularJs directive here https://docs.angularjs.org/guide/directive 您可以在此处https://docs.angularjs.org/guide/directive了解更多有关angularJs指令的信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM