β 1
angular ng-click (plunker)
<button ng-click="showValuePopup = !showValuePopup;">Click</button>
<div ng-show="showValuePopup">
<ul>
<li ng-click="$parent.showValuePopup = false;" ng-repeat="option in options" value="{{ option.value }}"
symbol="{{ option.symbol }}">{{ option.text }}
</li>
</ul>
</div>
β2
, ng-repeat (plunker)
app.directive('onLastRepeat', function () {
return function (scope, element, attrs) {
if (scope.$last) setTimeout(function () {
debugger;
scope.$emit('onRepeatLast', element, attrs);
}, 1);
};
});
:
$scope.$on('onRepeatLast', function(scope, element, attrs){
valuePopup.find('li').on('click',function(){
valuePopup.hide();
});
valuePopup.find('keydown').on('click',function(){
valuePopup.hide();
});
});