Skip to content

Commit 8b308a1

Browse files
author
Adam Bradley
committed
feat(event): Created stopEvent directive to use for certain ng-click cases, closes #550
1 parent 4cba7aa commit 8b308a1

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

Diff for: js/ext/angular/src/directive/ionicList.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ angular.module('ionic.ui.list', ['ngAnimate'])
2424

2525
template: '<div class="item item-complex">\
2626
<div class="item-edit" ng-if="deleteClick !== undefined">\
27-
<button class="button button-icon icon" ng-class="deleteIconClass" ng-click="deleteClick()"></button>\
27+
<button class="button button-icon icon" ng-class="deleteIconClass" ng-click="deleteClick()" stop-event="click"></button>\
2828
</div>\
2929
<a class="item-content" ng-href="{{ href }}" ng-transclude></a>\
3030
<div class="item-drag" ng-if="reorderIconClass !== undefined">\
3131
<button data-ionic-action="reorder" class="button button-icon icon" ng-class="reorderIconClass"></button>\
3232
</div>\
3333
<div class="item-options" ng-if="itemOptionButtons">\
34-
<button ng-click="b.onTap(item, b)" class="button" ng-class="b.type" ng-repeat="b in itemOptionButtons" ng-bind="b.text"></button>\
34+
<button ng-click="b.onTap(item, b)" stop-event="click" class="button" ng-class="b.type" ng-repeat="b in itemOptionButtons" ng-bind="b.text"></button>\
3535
</div>\
3636
</div>',
3737

Diff for: js/ext/angular/src/directive/ionicTouch.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,19 @@ angular.module('ionic.ui.touch', [])
4545

4646
};
4747

48-
}]);
48+
}])
49+
50+
.directive('stopEvent', function () {
51+
function stopEvent(e) {
52+
e.stopPropagation();
53+
}
54+
return {
55+
restrict: 'A',
56+
link: function (scope, element, attr) {
57+
element.bind(attr.stopEvent, stopEvent);
58+
}
59+
};
60+
});
4961

5062

5163
})(window.angular, window.ionic);

Diff for: js/ext/angular/test/list.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ <h1 class="title">List Tests</h1>
109109
option-buttons="optionButtons1">
110110

111111
<!-- shows that the item directive does not need attributes and can get values from the list attributes -->
112-
<item item="item" class="item-message" ng-repeat="item in items" ng-class="{ active: item.isActive}">
112+
<item item="item" ng-click="itemClick()" class="item-message" ng-repeat="item in items" ng-class="{ active: item.isActive}">
113113
<img ng-src="{{item.face}}">
114114
<h2>{{item.from}}</h2>
115115
<p>{{item.text}}</p>
@@ -210,6 +210,10 @@ <h1>YELLOW {{slideBox.slideIndex}}</h1>
210210
};
211211

212212

213+
$scope.itemClick = function() {
214+
console.debug('itemClick');
215+
};
216+
213217
// Item Methods/Properties
214218
$scope.deleteItem = function(item) {
215219
alert('onDelete from the "item" directive on-delete attribute. Lets not delete this item today ok!');

0 commit comments

Comments
 (0)