Hi I am here again
Sometimes I feel stupid doing this questions. But Then you help me
I am playing with auth-token-auth library connecting to a rails backend. For now, again, the stupid problem that I have it’s that registration fields on form are not mapping in javascript
This is my form:
<form ng-submit="register(registrationForm)" role="form" ng-init="registrationForm = {}" class="ng-dirty ng-valid-email ng-valid-parse ng-valid ng-valid-required ng-submitted">
<div class="form-group">
<label class="item item-input light-color">
<input type="text" placeholder="Introduce el nick name" id="nickname" name="nickname" ng-model="registrationForm.nickname">
</label>
</div>
<div class="form-group">
<label class="item item-input light-color">
<input type="email" placeholder="Introduce el email" id="email" name="email" ng-model="registrationForm.email">
</label>
</div>
<div class="form-group">
<label class="item item-input light-color">
<input type="password" placeholder="Introduce el password" id="password" name="password" ng-model="registrationForm.password">
</label>
</div>
<div class="form-group">
<label class="item item-input light-color">
<input type="password" placeholder="Repite el password" id="password_confirmation" name="password_confirmation" ng-model="registrationForm.password_confirmation">
</label>
</div>
<button id="reg-submit" type="submit" class="button button-block button-dark">Registrarse</button>
</form>
And this is my register.js
(function(){
'use strict';
var app = angular.module('ualaroo.register',[]);
app.controller('RegisterCtrl', function($scope, $http, $state, $ionicViewService, $ionicModal, $auth) {
'use strict';
$scope.message = '';
$scope.register = function() {
$auth.submitRegistration($scope.registrationForm)
.then(function(resp) {
// handle success response
})
.catch(function(resp) {
var error = 'Register failed:' + resp;
$scope.message = error;
});
//AuthenticationService.register($scope.user);
};
$ionicModal.fromTemplateUrl('registermodal.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
});
$scope.openModal = function() {
$scope.modal.show();
};
$scope.goToLogin = function() {
$scope.modal.hide();
$scope.username = null;
$scope.password = null;
$ionicViewService.nextViewOptions({
disableBack: true
});
$state.go('app.login', {'message':'You will receive a confirmation mail'}, {reload: true, inherit: false});
};
$scope.$on('$destroy', function() {
$scope.modal.remove();
});
$scope.$on('auth:registration-email-success', function(ev, message) {
$scope.openModal();
});
$scope.$on('auth:registration-email-error', function(ev, reason) {
var error = 'Register failed:' + reason.errors[0];
$scope.message = error;
});
});
})();
My problem is that $scope.registrationForm appears as undefined. And I don’t understand why, in theory the ng-model it’s ok. And I understand that I don’t need to inicialize nothing in javascript…
Thanks in advance