I have the following code which sends a request to server validate if the email already exists or not. Its working fine, but the problem is I am using the same directive on modify page. On modify page I want to send another param to server to ignore this email.
.directive('uniqueEmail', function($http) {
return {
require: 'ngModel',
link: function(scope, ele, attrs, c) {
var ignoreEmail= //here I want to save originol email;
scope.$watch(attrs.ngModel, function() {
$http({
method: 'GET',
url: '/MY/system/users/checkEmail?'+ $.param({'emailAddress': ele.val(), 'ignoreEmail': ignoreEmail})
}).success(function(isUnique,status,headers,cfg) {
var iu = isUnique == 'true' ? true : false;
c.$setValidity('unique', iu);
}).error(function(data,status,headers,cfg) {
c.$setValidity('unique', false);
});
});
}
}
});
How can I get the the origonal email in ignoreEmail so that can send to the server
var ignoreEmail=ele.val();