我为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);
}
}
}
]
});
};