有一个uib-tabset和一个等待uib-tabset内输入更改的指令,这个指令会到达,但当它必须触发一个作用域时。
视图
<uib-tabset active="active">
<uib-tab>
<input type="file" class="upload" share-all="" accept="image/*">服务/指令
.directive('shareAll', [function() {
return {
restrict: 'A',
link: function(scope, elem, attr) {
$(elem).on('change', function(event) {
return scope.$broadcast('shareIt', elem);
}
}
}
});控制器
$scope.$on('shareIt', function(event, file) {
});我看到了这个(https://github.com/angular-ui/bootstrap/issues/1553),但什么也不懂,这让我很痛苦。
有什么想法?
发布于 2017-04-06 22:02:57
我不认为你需要jQuery $对象,elem已经是一个jqLite对象(除非你有jQuery,否则elem已经是$的别名)。
你也没有正确关闭你的函数。
app.directive('shareAll', [function() {
return {
restrict: 'A',
link: function(scope, elem, attr) {
elem.on('change', function(event) {
return scope.$broadcast('shareIt', elem);
})
}
}
}]);https://stackoverflow.com/questions/43240037
复制相似问题