标签:
‘use strict‘; /* *检测用户名是否存在 */ angular.module(‘nswApp‘) .directive(‘checkname‘, function() { return { require: ‘ngModel‘, restrict: ‘A‘, scope: { checkName: ‘&checkName‘ } link: function(scope, elem, attrs, ctrl) { elem.on(‘blur‘, function() { var result = scope.checkName() .then(function(response) { if (response.value) { ctrl.$setValidity(‘checkname‘, false); } else { ctrl.$setValidity(‘checkname‘, true); } }, function(error) { }); }); } }; });
标签:
原文地址:http://www.cnblogs.com/happen-/p/5767246.html