【问题标题】:Angular modal service to popover弹出窗口的角度模态服务
【发布时间】:2015-05-31 08:58:36
【问题描述】:

我正在为模态框使用 Angular 指令

这是我的标记:

 <li><a ng-attr-title="{{::'Share'}}" 
        href="" class="shareButton" bh-model-ctrl="ShareArticleCtrl" 
        bh-template-html="shareArticleTemplate.html" 
        bh-alternate-id="items.alternate_id" 
        bh-title="items.bookmark_title" bh-url="items.bookmark_url" 
        bh-share-article></a></li>

指令代码就像

app.directive("bhShareArticle", ["$modal", "$window", function ($modal, $window) {
        return {
            restrict: 'A',
            scope: {
                alternateId: '=bhAlternateId',
                bookmarkTitle: '=bhTitle',
                bookmarkUrl: '=bhUrl'
            },
            link: function (scope, element, attrs) {
                element.click(function (event) {
                    event.stopPropagation();
                    var modalInstance = $modal.open({
                        templateUrl: attrs.bhTemplateHtml,
                        controller: attrs.bhModelCtrl,
                        size: 'sm',
                        resolve: {
                            bookmark: function () {
                                return {
                                    alternateId: scope.alternateId,
                                    bookmarkTitle: scope.bookmarkTitle,
                                    bookmarkUrl: scope.bookmarkUrl
                                };
                            }
                        }
                    });

                    modalInstance.result.then(function () {
                        if (attrs.redirect == "true") {
                            $window.location.href = '/user/dashboard';
                        }
                    }, function () {
                    //$log.info('Modal dismissed at: ' + new Date());
                    });
                });

                scope.$on('$destroy', function () {
                    element.off('click');
                });
            }
        };
    }]);

哪个工作正常。现在我们要变成popover

我们能轻松做到吗?

谢谢

【问题讨论】:

    标签: jquery angularjs angularjs-directive angular-ui


    【解决方案1】:

    使用https://angular-ui.github.io/bootstrap/#/popover。 我认为您只需要在主控制器中执行逻辑即可。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多