我正在尝试使用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.
}
我在这里做错了吗?
答案 0 :(得分:1)
我认为您需要执行ng-touch="beginInterest($event)"
,并且您需要加载angular-touch.js
并对您的应用依赖项ngTouch
加上angular.module('myApp',['ngTouch'])
。例如{{1}}。文档:{{3} }
答案 1 :(得分:0)
您需要删除type="submit"
<button on-touch="beginInterest()" class="button button-block button-positive">Create Task</button>