在角皮带的$ modal中捕获皮革事件 [英] Capture hide event in $modal of angular strap

查看:104
本文介绍了在角皮带的$ modal中捕获皮革事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Angle Strap创建像这样的模态:

I am using angular Strap to create a modal like :

$modal({
  template : "/templ/alert-with-title.html",
  content : content,
  title : title,
  show : true,
  backdrop : true,
  placement : 'center'
});

我写了以下内容:

$scope.$on("modal.hide.before",function() {
  console.log("Closing1");
});
$scope.$on("modal.hide",function() {
  console.log("Closin2");
});

我的/templ/alert-with-title.html是这样的:

<div aria-hidden="true" aria-labelledby="windowTitleLabel" role="dialog"
    tabindex="-1" class="modal hide fade in modal" id="">
    <div class="modal-header">
        <a class="fui-cross pull-right" ng-click="$hide()"></a>
        <h3 ng-bind="title"></h3>
    </div>
    <div class="modal-body">
        <div class="divDialogElements" >
            <span ng-bind="content"></span>
        </div>
    </div>
    <div class="modal-footer">
        <div>
            <button type="button" ng-click="$hide()"
                class="btn btn-default btn-gray-l gray pull-left mar_t-4">OK</button>
        </div>
    </div>
</div>

但是,即使如此,单击确定"时也没有控制台日志.为什么会这样?

However even after all this, I get no console logs when i click Ok. Why is this?

推荐答案

所以解决方案非常简单,我必须将范围提供给$ modal.

so the solution is very simple, I had to provide the scope to the $modal.

$modal({
  template : "/templ/alert-with-title.html",
  content : content,
  title : title,
  show : true,
  backdrop : true,
  placement : 'center',
  scope : $scope
});

但是我不明白为什么对于"$ emit"事件,外部作用域上的$ on不起作用

But what I do not understand that why for an event that is "$emit" , $on of the outside scope would not work

这篇关于在角皮带的$ modal中捕获皮革事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆