[英]onclick and ng-click event not working
我正在使用Onsen UI(angularjs)+ Cordova,但我遇到了以下問題:我有一個目前無法正常使用的按鈕,但該按鈕在某個時候可以使用。 現在,我什至無法獲得按鈕的點擊事件。 有人知道是什么問題嗎?
HTML:
<ons-list id="list-actions" style="border-top: none"><ons-list-item style="line-height: 1; padding: 0;">
<ons-row class="action">
<ons-col class="bt-pres action-col col {{interaction[0].present}}">
<div class="action-icon"><ons-icon icon="ion-fireball"></ons-icon></div>
<div class="action-label">Press</div>
</ons-col>
使用Javascript:
//not working
$(document).on("click",".bt-pres",function(){
alert("clicked");
感謝您的回復。 一遍又一遍地查看代碼,我的壞處是我有兩次代碼,例如$(document).on('click', elem, func)
並且發生沖突。 然后我將其更改為在控制器內部使用angular ngclick函數。 這就像一個魅力。 謝謝你們
首先, alert()
在波紋或設備中都不起作用(據我所知)。 如果您想觸發該功能,我建議ng-click()
HTML示例
<div ng-controller="LoginController">
<ons-button ng-click="Login()">Login</ons-button>
</div>
JS
.controller('LoginController', function () {
$scope.Login = function () {
console.log("triggered");
}
}
在你的情況下嘗試下面的代碼
$(document).on("click","div.action-label",function(){
console.log("triggered");
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.