1

我想寫一個小部件,它會顯示在按鈕單擊。 這是我想要實現的jQuery表示形式。 jQuery (This is not my code. Found this one on net) 我不知道如何繼續發展。該指令是否需要元素或屬性或其他內容。 我還沒有測試過這個,因爲我不知道要怎麼做。這是我計劃要做的。使用jQuery的角度小部件

angular.module('common').directive('shareModal',function(){ 

return { 
    restrict: 'E', 
    show: '=', 
    transclude: true, 
    replace: true, 
    template: '', 
    link: function (scope, elem, attrs) { 

     $(elem).click (function() { 
      var $this = $(this); 
      $("#background").css({ 
       "opacity": "0.3" 
      }).fadeIn("slow"); 

      $("#large").html(function() { 
       $('.ttip').css({ 
            left: $this.position() + '20px', 
            top: $this.position() + '50px' 
           }).show(500) 

      }).fadeIn("slow"); 

      $('.note').on('click', function() { 
       $('.ttip').hide(500); 
       $("#background").fadeOut("slow"); 
       $("#large").fadeOut("slow"); 

      }); 
      $("#large").click(function() { 
       $(this).fadeOut(); 
      }) 
     }) 
    } 
}}); 

在此先感謝。

更新: 自定義彈出式窗口是我想要實現的。 Custom Popover

+0

此外,得到一個 未知提供商:$ popoverProvider < - $酥料餅< - shareModalDirective錯誤。 錯誤我相信是由於沒有[控制器](https://docs.angularjs.org/error/$injector/unpr?p0=scopeProvider%20%3C-%20scope%20%3C-%20shareModalDirective) – batmaniac7 2014-09-29 23:51:44

回答

0

我通過注射模塊固定它mgcrea.ngStrap「

+0

哇!我已經忘記了這一點。感謝更新。 – batmaniac7 2015-09-10 16:27:55