Is there a way to validate one or multiple email addresses in a single input field?
The way that I'm currently exploring is by creating a custom directive that will split the input into different emails if a comma is detected. This is what I have so far:
angular.module('myApp')
.directive('multipleEmails', function () {
return {
require: 'ngModel',
link: function(scope, element, attrs, ctrl) {
ctrl.$parsers.unshift(function(viewValue) {
var emails = viewValue.split(',');
// loop that checks every email, returns undefined if one of them fails.
});
}
};
});
The issue that I have with this is that I have been unable to call the angular email validator manually.
Edit: plunkr
Edit 2: Turns out that I can use angular 1.3