我有一个奇怪的问题,触摸事件没有触发ng-submit
或ng-click
(在 chrome 设备开发工具中)。Chrome 开发工具模拟 touchstart/touchend 事件,所以我不确定为什么这不起作用。它在桌面上运行良好。
给定以下 HTML 表单:
<form subscribe-to-newsletter ng-submit="subscribe.submitEmailSubscribe()" ng-class="{ error : subscribe.states.error, success : subscribe.states.success }">
<div class="status-icon loading" ng-show="subscribe.states.loading"><i class="fa fa-circle-o-notch fa-spin"></i></div>
<div class="status-icon success" ng-show="subscribe.states.success"><i class="fa fa-check"></i> Subscribed!</div>
<input type="email" placeholder="Email Address" ng-model="subscribe.email">
<button type="submit" class="hollow">Subscribe to newsletter</button>
</form>
以及以下指令/控制器:
angular.module('quiip.directives')
.directive('subscribeToNewsletter', subscribeToNewsletterDirective);
function subscribeToNewsletterDirective(){
return {
restrict: 'A',
scope: {},
bindToController: {},
controllerAs: 'subscribe',
controller: subscribeToNewsletterCtrl,
link: function(scope, el){
el.addClass('subscribe-to-newsletter');
}
}
}
function subscribeToNewsletterCtrl($scope, $http){
this.states = {
loading: false,
success: false,
error: false
};
this.email = '';
this.submitEmailSubscribe = function(){
console.log('submitting');
}
}
控制台日志从不注册。它在桌面上运行良好。奇怪的是该类ng-submitted
被添加到表单中。
我错过了一些与ng-submit
触摸事件有关的东西吗?