Javascript Ionic AngularJS所有ng点击事件都触发了两次?
在我的Ionic应用程序中,我的ng click事件触发了两次,我还没有找到解决方法。为了测试此错误,我将代码压缩为以下内容(错误仍然发生在iOS emulator和iOS设备上,但不在浏览器或android上): 正在运行的版本(由浏览器呈现,不产生错误): JS HTMLJavascript Ionic AngularJS所有ng点击事件都触发了两次?,javascript,html,angularjs,ionic,Javascript,Html,Angularjs,Ionic,在我的Ionic应用程序中,我的ng click事件触发了两次,我还没有找到解决方法。为了测试此错误,我将代码压缩为以下内容(错误仍然发生在iOS emulator和iOS设备上,但不在浏览器或android上): 正在运行的版本(由浏览器呈现,不产生错误): JS HTML 无伤害安全应用 测试点击 非常感谢您的帮助 这是当前爱奥尼亚的一个bug。这是由于alert()和$window.alert()函数造成的。我已经在这里发布了这个问题:formnovalidate的指令如何formno
无伤害安全应用
测试点击
非常感谢您的帮助 这是当前爱奥尼亚的一个bug。这是由于alert()和$window.alert()函数造成的。我已经在这里发布了这个问题:formnovalidate的指令如何
formnovalidate
是自定义指令吗?如果是-有任何点击事件吗?没有,我刚从我的代码中删除了它,错误仍然发生。你能做plunkr吗?因为我们没有发现这个代码有任何错误。这是您的运行代码。没什么问题。你为什么要把你所有的angular应用程序代码包装在一个函数中?
(function() {
var app = angular.module('nh-launch', ['ionic']);
app.controller('testCtrl', function($scope) {
$scope.testClick = function () {
alert("hello");
};
});
}());
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>NoHarm Safety Application</title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="lib/ngCordova/dist/ng-cordova.js"></script>
<script src="lib/angular-resource/angular-resource.js"></script>
<script src="lib/angular-random-string/src/angular-random-string.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
</head>
<body ng-app="nh-launch">
<ion-pane>
<ion-content>
<div ng-controller="testCtrl">
<button ng-click="testClick()" class="button button-block button-calm">Test Click</button>
</div>
</ion-content>
</ion-pane>
</body>
</html>