我正在开发一个phonegap应用。我希望通过$ ionicpopup获得用户评论,代码如下:
function showToast(message) {
if (window.plugins && window.plugins.toast) {
window.plugins.toast.showLongCenter(message);
}
else $ionicLoading.show({ template: message, noBackdrop: true, duration: 2000 });
}
$scope.showPopup = function () {
$scope.data = {};
var pop=$ionicPopup.show({
template: '<div class="list" dir="rtl"><label class="item item-input"><input ng-model="cmnt.name" type="text" placeholder="name"></label><label class="item item-input"><textarea ng-model="cmnt.body" rows="4" placeholder=" comment..."></textarea></label></div>',
title: 'write your comment',
subTitle: '',
scope: $scope,
buttons: [
{
text: 'cancel',
type: 'button-small'
},
{
text: '<b>save</b>',
type: 'button-energized',
onTap: function (e) {
return $scope.cmnt;
}
}
]
}).then(function (res) {
jQuery.post(mysite + "home/addComment",
{ registerID: localStorage.getItem("regID"), name: res.name, body:res.body, gameID: $scope.gameID })
.success(function (text) {
result = JSON.stringify(text);
showToast('result');
}).error(function (e) {
showToast("Error! ");
})
});
}
但是当&#34; Save&#34;点击按钮什么都不会发生。这是为什么?怎么了??? ps:我发现问题出在&#34;返回$ scope.cmnt&#34;但我不知道如何解决它。