Angular 表带 - 警报不适用于指令

Angular Strap - alerts doen't work with directives

我写了指令在某些范围内显示通知: 但是,bootstrap strap(http://mgcrea.github.io/angular-strap/#/alerts) 警报服务没有向我的指令容器添加警报,为什么?

  app.directive("notification", function ($alert, $rootScope) {
        return {
            restrict: "E",
            template: '<div></div>',
            link: function (scope, element) {
                var id = "#alerts-container" + getRandomId();
                element.attr("id", id);
                scope.$on('notificationEvent', function (event, alertArg) {
                    var alert = angular.extend(alertArg, {container: id});
                    console.log(alert);
                    $alert(alert);
                    event.preventDefault();
                });

            }
        };
    });

页数:

<notification>
</notification>

所有事件都已处理,当 notificationEvent 为 运行 时没有错误,但我的通知容器始终为空。你能帮帮我吗?

谢谢!

您似乎只设置了 id 而不是选择器 ('#' + id)。

这是我的错误:id - 不正确; attr('id', '#id') - #...