我有一个AngularJS应用程序,我在Cordova(Android)上运行。它连接到Firebase数据库并推送对象。
它适用于Chrome,适用于Cordova(Android)。但是,在Android上,如果我点击调出键盘的textarea,对象就不会再被推送到Firebase。
有谁知道错误是什么?
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.13/angular.min.js"></script>
<script src='https://cdn.firebase.com/js/client/1.0.17/firebase.js'></script>
<meta charset=utf-8 />
<title>Angular JS Demo</title>
</head>
<body ng-controller="ctrl">
<h1>Comments</h1>
<div class="row">
<div class="small-12 columns">
<form novalidate>
<textarea placeholder="Add comment" ng-model="comment.text"></textarea>
<button type="submit" class="tiny button pull-right" ng-click="addTestComment(comment)">Add Comment</button>
</form>
</div>
</div>
</div>
<script type="text/javascript">
var firebase_url = "https://<secret>.firebaseio.com";
function ctrl($scope){
$scope.comment = {'text':'Placeholder comment'};
$scope.addTestComment = function(comment) {
var cmt = {'text':'Test Comment 1', 'created':new Date().getTime()};
cmt.text = comment.text;
var ref = new Firebase(firebase_url).child('comments-test');
ref.push(cmt);
};
}
</script>
</body>
</html>
答案 0 :(得分:1)
我忘了在我的HTML中包含cordova.js。包括它解决了这个问题:
<script src="cordova.js"></script>