'use strict'; /** * controllers for ng-table * Simple table with sorting and filtering on AngularJS */ app.controller('forgotCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootScope', '$cookies', 'md5','ipCookie', 'SweetAlert', function ($scope, $http, apiPoint, $state, $rootScope, $cookies, md5, ipCookie, SweetAlert) { /** * login details capture * by : srk */ // $scope.myModel = { 'userMobile': '', }; $scope.show = false; $scope.responseData = ''; $scope.forgotForm = { submit: function (form) { //alert("hi"); var firstError = null; if (form.$invalid) { var field = null, firstError = null; for (field in form) { if (field[0] != '$') { if (firstError === null && !form[field].$valid) { firstError = form[field].$name; } if (form[field].$pristine) { form[field].$dirty = true; } } } angular.element('.ng-invalid[name=' + firstError + ']').focus(); } else { $scope.spin = ''; var req = { method: 'POST', url: apiPoint.url + 'forgetlogin/', headers: { 'Content-Type': 'application/json' }, data: { userMobile: $scope.myModel.userMobile, // password: md5.createHash($scope.myModel.password || '') } }; $http(req).then(function (response) { if (response.data.forgotstatus == true) { // $scope.responseData = response.data.forgotstatus; //alert(response.data.message); swal("Success!",response.data.resPass, "success"); $state.go('login.signin'); } else { //alert(response.data.message); swal("Failed!", response.data.message, "error"); // $scope.show = true; // $(".alert").delay(200).addClass("in").fadeOut(3500); } }); // // } }, reset: function (form) { $scope.myModel = angular.copy($scope.master); form.$setPristine(true); } } }]); // forgetLogin -> Number(9876543210) -> (is he/she exist) yes---> genetate(md5(venba@123)) --> response(true check your mail, venba@123) // no --> response(not exist)