app.directive('expandingTile', [function() {
return {
restrict: 'A',
link: function(scope, elem, attrs) {
elem.bind('click', function() {
console.log('elem hit!');
});
elem.find('div#CloseBtn').bind('click', function() {
console.log('found child hit!')
});
}
}
}]);
答案 0 :(得分:4)
尝试使用此
link: function (scope, element) {
$timeout(function () {
element.on('click', '#Id', function () {
console.log('inside event handler of the first child)
})
})
}
不要忘记在指令
中注入$ timeout