【问题标题】:not getting angular ui bootstrap popover没有得到角度的ui引导弹出窗口
【发布时间】:2015-06-26 05:43:49
【问题描述】:

我试图在悬停时在我的<a> 上获得弹出框,如自定义指令中的here 所示。但它没有让我弹出框。这里出了什么问题。检查小提琴以查看我的整个指令定义.

 template: '<h1><a  popover-placement="bottom" popover="sd"  popover-trigger="mouseenter">{{pages}}</a></h1>',

【问题讨论】:

    标签: angularjs angular-ui angular-ui-bootstrap


    【解决方案1】:

    您需要添加 UI Bootstrap 依赖项。所以你的模块定义应该是:

    var MyDirectives = angular.module('testapp', ['ui.bootstrap']);
    

    演示: http://jsfiddle.net/PfEaz/15/

    【讨论】:

      【解决方案2】:

      你只需要做两件事:

      1. 添加模块依赖,使其能够找到弹出框

      2. 为 bootstrap 添加 css 以获得更好的视觉效果

      HTML:

      <div ng-app="testapp">
          <div ng-controller="testCtrlr">
              <div mdpagination pages="pages"></div>
          </div>
      </div>
      

      控制器:

      var MyDirectives = angular.module('testapp', ['ui.bootstrap']);
      
      MyDirectives.controller('testCtrlr', ['$scope', function ($scope) {
          $scope.pages = 'hover me to get popover'
      }]);
      
          MyDirectives.directive("mdpagination", function () {
              console.log('DIRECTIVE!');
              return {
                  template: '<h1><a popover-placement="bottom" popover="sd"  popover-trigger="mouseenter">{{pages}}</a></h1>',
                  replace: true,
                  restrict: 'A',
                  // scope: {pages:'@'}, //default
                  link: function (scope, element, attrs) {
                      console.dir(scope.pages);
                  }
              }
          });
      

      【讨论】:

        猜你喜欢
        • 2016-09-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-26
        • 2014-10-02
        • 1970-01-01
        • 2016-07-26
        • 1970-01-01
        相关资源
        最近更新 更多