mirror of
https://github.com/bitwarden/web
synced 2025-12-15 07:43:16 +00:00
reorganize project folder structure and remove asp.net dependency
This commit is contained in:
30
src/app/directives/apiFieldDirective.js
Normal file
30
src/app/directives/apiFieldDirective.js
Normal file
@@ -0,0 +1,30 @@
|
||||
angular
|
||||
.module('bit.directives')
|
||||
|
||||
.directive('apiField', function () {
|
||||
var linkFn = function (scope, element, attrs, ngModel) {
|
||||
ngModel.$registerApiError = registerApiError;
|
||||
ngModel.$validators.apiValidate = apiValidator;
|
||||
|
||||
function apiValidator() {
|
||||
ngModel.$setValidity('api', true);
|
||||
return true;
|
||||
}
|
||||
|
||||
function registerApiError() {
|
||||
ngModel.$setValidity('api', false);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
require: 'ngModel',
|
||||
restrict: 'A',
|
||||
compile: function (elem, attrs) {
|
||||
if (!attrs.name || attrs.name === '') {
|
||||
throw 'api-field element does not have a valid name attribute';
|
||||
}
|
||||
|
||||
return linkFn;
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user