Javascript Ionic Angularjs表单使用$cordovaDialog触发两次
我正在通过Ionic live reload运行此功能,出于某种原因,当我单击“验证”按钮时,Javascript Ionic Angularjs表单使用$cordovaDialog触发两次,javascript,angularjs,cordova,ionic-framework,cordova-plugins,Javascript,Angularjs,Cordova,Ionic Framework,Cordova Plugins,我正在通过Ionic live reload运行此功能,出于某种原因,当我单击“验证”按钮时,identify()函数会运行两次,除非我执行下面定义的某些操作 如果有人有任何建议,我们将不胜感激 如果我单击enter,它只运行一次 如果我注释掉下面的代码,它也只运行一次 控制器中的以下代码: //if(resp == false) $cordovaDialogs.alert('ID Not Found', 'Not Found', 'Try Again'); //else $cordova
identify()
函数会运行两次,除非我执行下面定义的某些操作
如果有人有任何建议,我们将不胜感激
- 如果我单击enter,它只运行一次
- 如果我注释掉下面的代码,它也只运行一次
//if(resp == false) $cordovaDialogs.alert('ID Not Found', 'Not Found', 'Try Again');
//else $cordovaDialogs.alert('We were not able to load up the user database.', 'Error', 'Try Again');
这是我的密码 HTML
<div id="loginBox">
<form name="id_frm" ng-submit="id_frm.$valid && identify()" novalidate>
<input name="id" ng-model="id" type="text" placeholder="type id number" required />
<button name="submit" type="submit">{{ identify_button || "Verify" }}</button>
</form>
</div>
数据库服务
self.findUser = function(idnum) {
return $q.when(self.db.query('filters/users'))
.then(function(resp) {
var found = false, found_id;
angular.forEach(resp.rows, function(u, id) { if(u.value == idnum) { found = true; found_id = u.id; } });
if(found) return found_id; else return false;
})
.catch(function(resp) { console.log(JSON.stringify(resp)); return null; })
}
self.findUser = function(idnum) {
return $q.when(self.db.query('filters/users'))
.then(function(resp) {
var found = false, found_id;
angular.forEach(resp.rows, function(u, id) { if(u.value == idnum) { found = true; found_id = u.id; } });
if(found) return found_id; else return false;
})
.catch(function(resp) { console.log(JSON.stringify(resp)); return null; })
}