var app = angular.module('part3', []);
app.controller('Part3Controller' ,function ($scope) {
$scope.Message1 = "apek";
$scope.IsLogedIn = false;
$scope.Message = '';
$scope.Submitted = false;
$scope.IsFormValid = false;
$scope.LoginData = {
UserName: '',
Password: ''
};
$scope.$watch('f1.$valid', function (newVal) {
$scope.IsFormValid = newVal;
});
$scope.Login = function () {
$scope.Submitted = true;
if ($scope.IsFormValid) {
alert("eeeeee")
alert("dsds")
serv.GetUser($scope.LoginData).then(function (d) {
alert("dsdsdfsdfs");
if (d.data.UserName != null) {
alert("he;llo1");
$scope.IsLoggedIn = true;
$scope.Message = "Successfully Login" + d.data.FullName;
}
else {
alert("Invalid Credential")
}
})
}
}
})
app.factory('serv', function ($http) {
alert("helloo");
var fac = {};
fac.GetUser = function (d) {
$scope.Submitted = true;
return $http({
url: '/Data/UserLogin',
method: 'POST',
data: JSON.stringify(d),
header: { 'content-type': 'application/json' }
});
};
return fac;
});
I had written above code for login functionality in my app but it is not calling factory "serv" its showing error "angular.min.js:92 ReferenceError: serv is not defined"
"angular.min.js:92 ReferenceError: serv is not defined"