The following code is a login form. With this i am able to reset the form fields and error messages on first time(both success or failure works first time). Second time i am not able to rest form fields. Also the login process also fails and doesn't show failure or success. Because the data is undefined now and On console it throw error 415(Unsupported Media Type). If i remove the reset part, the login process is working properly. What i am doing wrong with reset?
In controller:
App.controller('HomeCtrl', ['$scope', 'Users', '$window', '$location', '$rootScope',
function($scope, Users, $window, $location, $rootScope) {
var original = $scope.users;
$scope.users = {};
$scope.form = {};
$scope.reset = function() {
$scope.users = angular.copy(original);
$scope.form.loginForm.$setPristine();
};
} ]);