I found this code snippet on a blog post about validation in Ionic apps, you can check it out here
While working on designing a login form in Ionic, I encountered two issues:
1. I'm confused about why there are 2 submits used in the example:
<form name="signinForm" novalidate="" ng-submit="signIn(signinForm)">
and:
<button class="button button-block button-positive" ng-click="signIn(user)">
2. When trying to clear the input fields using:
$scope.user.remove();
An error occurs:
TypeError: Cannot read property 'remove' of undefined
This is how my code currently looks:
$scope.$on('event:auth-loginConfirmed', function() {
$scope.user.remove();
$state.go('app.placeslists');
});
$scope.signIn = function(form) {
if (form.$valid) {
AuthenticationService.login($scope.user);
}
};