I looked at a bunch of AngularJS directives checking for uniqueness of a username and decided to try for the simplest implementation. It does what I want but may not really be 'idiomatic' Angular.Here is the form element:<input type=text    name=username    ng-model=form.username    unique-username=    required/><span class=hide-while-in-focus ng-show=thisform.username.$error.unique>Username taken!</span>Here's the directive:.directive('uniqueUsername', function($http) {      return {           restrict: 'A',           require: 'ngModel',           link: function (scope, element, attrs, ngModel) {                element.bind('blur', function (e) {                     ngModel.$setValidity('unique', true);                     $http.get(/api/checkUnique/ + element.val()).success(function(data) {                          if (data) {                              ngModel.$setValidity('unique', false);                          }                     });                });           }      };})And the ExpressJS call:if (data) {      console.log(found  + data.username);      return res.send(data.username);}else {      console.log(not found);      return res.send(404);}I would appreciate any feedback on why this is good or bad and if possible a revision that uses $scope.watch on the model. 
Angular directive for unique username
javascript;angular.js