Reputation:
if Entered Email length count>0 comeses in else out please suggest me where i'm doing mistake
$scope.CheckEmail = function () {
var x = {
Email: $scope.Email
}
if (x.length >= 0) {
var check = MyService.ChkMail(x);
check.then(function (d) {
$scope.Valid = d.data;
})
}
Upvotes: 0
Views: 782
Reputation: 11
If you just want to check length > 0 , I would suggest to use the required
attribute on your input, and then check your form with angular like
<form name="form" novaldiate>
<input type="email" ng-model="Email" name="Email" required>
</form>
Then you can check :
Is this is a valid Email ? {{form.Email.$valid}}
(easier if you email come from a form)
Upvotes: 0
Reputation: 334
You are assigning x to an object. Therefore x.length
will always return undefined
. You can assign x directly to your scope variable:
$scope.CheckEmail = function () {
var x = $scope.Email;
if (x.length >= 0) {
var check = MyService.ChkMail(x);
check.then(function (d) {
$scope.Valid = d.data;
})
}
Upvotes: 0
Reputation: 610
Please use following -
$scope.CheckEmail = function () {
var x = {
Email: $scope.Email
}
if (x.Email.length >= 0) {
var check = MyService.ChkMail(x);
check.then(function (d) {
$scope.Valid = d.data;
})
}
Hope this will work..
Upvotes: 1
Reputation: 41387
u need to access the Email property of the x object
if (x.Email.length >= 0) {
var check = MyService.ChkMail(x);
check.then(function (d) {
$scope.Valid = d.data;
})
}
Upvotes: 1