I am trying to use the code from here
I am trying to design a login form in Ionic but I am facing two issues:
1.Cant understand why have they used 2 submits in the example:
<form name="signinForm" novalidate="" ng-submit="signIn(signinForm)">
and:
<button class="button button-block button-positive" ng-click="signIn(user)">
2.I get an error when I am trying to clean the fields using:
$scope.user.remove();
The error:
TypeError: Cannot read property 'remove' of undefined
My code looks like:
$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:
I cannot be sure why that coder chose to add 2 submit events, but I just removed the ng-click
and it works fine, because we are not requiring the user
object, since it already is in the scope. So you can remove ng-click
from the button.
- I get an error when I am trying to clean the fields using:
This should work to empty your fields:
$scope.user = { username: '', password: '' };
This code will empty your user
scope.
remove()
won't work like this in AngularJS.