I have been working on creating a form that allows users to change their username. Below is the HTML code I have written:
<div ng-controller="manageProfile" >
<form>
<div class="form-group">
<label>Display Name</label>
<input type="text" ng-model="user.currentName" placeholder="Display Name">
</div>
<button ng-click="changeName()">Change Username</button>
</form>
</div>
Here is my AngularJs code:
var profile = angular.module('getUserInfo', ['ngParse']);
profile.controller('manageProfile', ['$scope', function($scope) {
$scope.changeName = function(form) {
var user = Parse.User.current();
user.setUsername(form.currentName);
user.save(null, {
success: function(user) {
console.log("Success");
},
error: function(error) {
console.log("Fail");
}
});
};
}]);
Upon clicking the Change Username
button, I encountered an error message stating: Error: form is undefined
. Can someone help me understand what went wrong and how I can fix it?