在 Ionic 中未接收到触摸事件数据
Not receiving touch event data in Ionic
我正在尝试使用 Ionic 框架做一些相当简单的事情。
<form>
<div class="list">
<div>
<img ng-src="some_image_source"></img>
</div>
<label class="item item-input">
<input type="text" placeholder="What do you need to do?" ng-model="task.title">
</label>
</div>
<div class="padding">
<button on-touch="beginInterest(event)" class="button button-block button-positive">Create Task</button>
</div>
我想在我的控制器中定义的 beginInterest 函数中捕获事件对象和来自此触摸事件的关联数据
$scope.beginInterest = function (event) {
// But there is no event object here! It's undefined.
}
我是不是做错了什么?
您需要删除 type="submit"
<button on-touch="beginInterest()" class="button button-block button-positive">Create Task</button>
我认为你需要做 ng-touch="beginInterest($event)"
并且你需要加载 angular-touch.js
并在你的应用程序依赖项上有 ngTouch
(例如 angular.module('myApp',['ngTouch'])
。文档在这里:https://docs.angularjs.org/api/ngTouch
我正在尝试使用 Ionic 框架做一些相当简单的事情。
<form>
<div class="list">
<div>
<img ng-src="some_image_source"></img>
</div>
<label class="item item-input">
<input type="text" placeholder="What do you need to do?" ng-model="task.title">
</label>
</div>
<div class="padding">
<button on-touch="beginInterest(event)" class="button button-block button-positive">Create Task</button>
</div>
我想在我的控制器中定义的 beginInterest 函数中捕获事件对象和来自此触摸事件的关联数据
$scope.beginInterest = function (event) {
// But there is no event object here! It's undefined.
}
我是不是做错了什么?
您需要删除 type="submit"
<button on-touch="beginInterest()" class="button button-block button-positive">Create Task</button>
我认为你需要做 ng-touch="beginInterest($event)"
并且你需要加载 angular-touch.js
并在你的应用程序依赖项上有 ngTouch
(例如 angular.module('myApp',['ngTouch'])
。文档在这里:https://docs.angularjs.org/api/ngTouch