简体   繁体   English

uib-tabset杀死了我的输入更改指令的范围

[英]uib-tabset killing the scope of my input change directive

Had a uib-tabset and a directive that wait for a change on an input inside the uib-tabset, this directive is reached but when it has to fire a scope.$broadcast this don't call the function. 如果有一个uib-tabset和一个等待uib-tabset内部输入更改的指令,则会到达此指令但是必须触发一个范围。$ broadcast这不会调用该函数。

View 视图

  <uib-tabset active="active">
     <uib-tab>
       <input type="file" class="upload" share-all="" accept="image/*">

Service/Directive 服务/指令

.directive('shareAll', [function() {
    return {
        restrict: 'A',
         link: function(scope, elem, attr) {
           $(elem).on('change', function(event) {
            return scope.$broadcast('shareIt', elem);
            }
        }
    }
});

Controller 调节器

$scope.$on('shareIt', function(event, file) {
});

I saw this ( https://github.com/angular-ui/bootstrap/issues/1553 ) but understood nothing at all, and this is killing me slowly. 我看到了这个( https://github.com/angular-ui/bootstrap/issues/1553 )但完全没有理解,这让我很慢。

Some thoughts? 一些想法?

I don't think you need that jQuery $ object, elem is already a jqLite object (unless you have jQuery, then elem is already an alias for $ ). 我认为你不需要那个jQuery $对象,elem已经是一个jqLit​​e对象了(除非你有jQuery,然后elem已经是$的别名)。

you also didn't closed your functions right. 你也没有关闭你的功能。

app.directive('shareAll', [function() {
    return {
        restrict: 'A',
        link: function(scope, elem, attr) {
            elem.on('change', function(event) {
                return scope.$broadcast('shareIt', elem);
            })
        }
    }
}]);

Here's a demo plunk 这是一个演示插件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM