我编写了指令以在一定范围内显示通知:但是,引导程序带(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)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句