Skip to content

Instantly share code, notes, and snippets.

@pjsvis
Forked from anonymous/gist:2716646
Created May 17, 2012 06:36
Show Gist options
  • Save pjsvis/2717022 to your computer and use it in GitHub Desktop.
Save pjsvis/2717022 to your computer and use it in GitHub Desktop.
angular.module('formComponents', [])
.directive('formInput', function() {
return {
restrict: 'E',
scope: {},
link: function(scope, element, attrs)
{
var type = attrs.type || 'text';
var required = attrs.hasOwnProperty('required') ? "required='required'" : "";
var htmlText = '<div class="control-group">' +
'<label class="control-label" for="' + attrs.formId + '">' + attrs.label + '</label>' +
'<div class="controls">' +
'<input type="' + type + '" class="input-xlarge" id="' + attrs.formId + '" name="' + attrs.formId + '" ' + required + '>' +
'</div>' +
'</div>';
element.html(htmlText);
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment