Below is the HTML code snippet provided:
<input ng-blur="CheckUser()" name="username" ng-model="RegisterFormData.username"
class="form-control"/>{{ a.check_username_result }}
I have assigned the controller and ng-app, everything is functioning well except for the issue of not being able to send back data after making an $http request. It keeps showing an error stating that the property of push() is undefined.
Here's the controller I am using where CheckUser() event should return certain data to the page after some operation. However, the push() function is throwing an error as undefined even though all other operations are executed successfully:
LoginApp.controller("RegisterController", function($scope, $http, registerService){
var username = null;
var password = null;
RegisterData = $scope.RegisterFormData;
$scope.CheckUser = function(RegisterData){
username = $scope.RegisterFormData.username;
console.log(username);
usernameResult = registerService.CheckUser(username);
if( usernameResult == "exists")
$scope.a.push({check_username_result : "Username already exists, Choose another."});
else if( usernameResult == 'fresh')
$scope.a.push({check_username_result : "Username available!"});
else
$scope.a.push({check_username_result : "Error. try again."});
}; // end of user_check()
$scope.registerSubmit = function(){
username = $scope.RegisterFormData.username;
password = $scope.RegisterFormData.password;
};
});