离子登录后无法清除表单
Unable to clear the form after login on ionic
我正在尝试使用 here
中的代码
我正在尝试在 Ionic 中设计一个登录表单,但我面临两个问题:
1.Cant 理解为什么他们在示例中使用了 2 个提交:
<form name="signinForm" novalidate="" ng-submit="signIn(signinForm)">
和:
<button class="button button-block button-positive" ng-click="signIn(user)">
2.I 当我尝试使用以下方式清理字段时出现错误:
$scope.user.remove();
错误:
TypeError: Cannot read property 'remove' of undefined
我的代码如下:
$scope.$on('event:auth-loginConfirmed', function() {
$scope.user.remove();
$state.go('app.placeslists');
});
$scope.signIn = function(form) {
if (form.$valid) {
AuthenticationService.login($scope.user);
}
};
- Cant understand why have they used 2 submits in the example:
我不确定为什么那个编码器选择添加 2 个提交事件,但我只是删除了 ng-click
并且它工作正常,因为我们不需要 user
对象,因为它已经在范围内。因此,您可以从按钮中删除 ng-click
。
- I get an error when I am trying to clean the fields using:
这应该可以清空您的字段:
$scope.user = { username: '', password: '' };
此代码将清空您的 user
范围。
remove()
在 AngularJS 中不会像这样工作。
我正在尝试使用 here
中的代码我正在尝试在 Ionic 中设计一个登录表单,但我面临两个问题:
1.Cant 理解为什么他们在示例中使用了 2 个提交:
<form name="signinForm" novalidate="" ng-submit="signIn(signinForm)">
和:
<button class="button button-block button-positive" ng-click="signIn(user)">
2.I 当我尝试使用以下方式清理字段时出现错误:
$scope.user.remove();
错误:
TypeError: Cannot read property 'remove' of undefined
我的代码如下:
$scope.$on('event:auth-loginConfirmed', function() {
$scope.user.remove();
$state.go('app.placeslists');
});
$scope.signIn = function(form) {
if (form.$valid) {
AuthenticationService.login($scope.user);
}
};
- Cant understand why have they used 2 submits in the example:
我不确定为什么那个编码器选择添加 2 个提交事件,但我只是删除了 ng-click
并且它工作正常,因为我们不需要 user
对象,因为它已经在范围内。因此,您可以从按钮中删除 ng-click
。
- I get an error when I am trying to clean the fields using:
这应该可以清空您的字段:
$scope.user = { username: '', password: '' };
此代码将清空您的 user
范围。
remove()
在 AngularJS 中不会像这样工作。