mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
bring back $ionicNgClick, but without having to use ionic tap
This commit is contained in:
36
js/angular/directive/ngClick.js
vendored
36
js/angular/directive/ngClick.js
vendored
@@ -1,8 +1,38 @@
|
||||
// Similar to Angular's ngTouch, however it uses Ionic's tap detection
|
||||
// and click simulation. ngClick
|
||||
|
||||
IonicModule
|
||||
|
||||
.config(['$provide', function($provide) {
|
||||
$provide.decorator('ngClickDirective', ['$delegate', function($delegate) {
|
||||
// drop the default ngClick directive
|
||||
$delegate.shift();
|
||||
return $delegate;
|
||||
}]);
|
||||
}])
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
.factory('$ionicNgClick', ['$parse', function($parse) {
|
||||
return function(scope, element, clickExpr) {
|
||||
var clickHandler = $parse(clickExpr);
|
||||
|
||||
element.on('click', function(event) {
|
||||
scope.$apply(function() {
|
||||
clickHandler(scope, {$event: (event)});
|
||||
});
|
||||
});
|
||||
|
||||
// Hack for iOS Safari's benefit. It goes searching for onclick handlers and is liable to click
|
||||
// something else nearby.
|
||||
element.onclick = function(event) { };
|
||||
};
|
||||
}])
|
||||
|
||||
.directive('ngClick', ['$ionicNgClick', function($ionicNgClick) {
|
||||
return function(scope, element, attr) {
|
||||
$ionicNgClick(scope, element, attr.ngClick);
|
||||
};
|
||||
}])
|
||||
|
||||
.directive('ionStopEvent', function () {
|
||||
function stopEvent(e) {
|
||||
e.stopPropagation();
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
ng-model="radioModel.data"
|
||||
ng-value="'Radio B'">Radio B</ion-radio>
|
||||
|
||||
</div>
|
||||
</ion-list>
|
||||
|
||||
<label class="label1">
|
||||
<input type="radio" name="radio" id="radio1" class="radio1">
|
||||
@@ -80,7 +80,7 @@
|
||||
</label>
|
||||
<input type="checkbox" name="checkbox2" id="checkbox2" class="checkbox2">
|
||||
|
||||
</ion-list>
|
||||
</div>
|
||||
|
||||
<div ng-show="testBtnText == 'AngJS'">
|
||||
<div class="list">
|
||||
|
||||
Reference in New Issue
Block a user