我为IonicPopup获取了示例代码,并将 wifi 密码条目修改为用户名和密码条目。它按预期工作,但如果您单击登录按钮而不输入用户名或密码,则所发生的一切都是e.preventDefault()
.
如果任一字段留空,有没有办法可以向弹出窗口添加动画,也许是“摇晃”动画?
$scope.promptLogin = function() {
$scope.data = {};
// An elaborate, custom popup
var myPopup = $ionicPopup.show({
template: '<input type="text" placeholder="Username" ng-model="data.user"><br><input type="password" placeholder="Password" ng-model="data.pass">',
title: 'Enter Credentials',
subTitle: '',
scope: $scope,
buttons: [
{ text: 'Cancel' },
{
text: '<b>Login</b>',
type: 'button-positive',
onTap: function(e) {
if (!$scope.data.user || !$scope.data.pass) {
//don't allow the user to close unless he enters a user and pass
e.preventDefault();
} else {
//console.log($scope.data.user + " - " + $scope.data.pass);
}
}
}
]
});
};