Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <div ng-repeat="content in vm.contents">
  2.  
  3. <form-el formId="content.id"
  4. type="content.type"
  5. label="content.label"
  6.  
  7. ></form-el>
  8. </div>
  9.  
  10. .directive('formEl', function () {
  11. return {
  12. restrict: 'E',
  13. compile: function(element, attrs) {
  14. var type = attrs.type || 'text';
  15. var required = attrs.hasOwnProperty('required') ? "required='required'" : "";
  16. if(type=='text'){
  17. var htmlText = '<div class="control-group">' +
  18. '<label class="control-label" for="' + attrs.formId + '">' + attrs.label + '</label>' +
  19. '<div class="controls">' +
  20. '<input type="' + type + '" class="input-xlarge" id="' + attrs.formId + '" name="' + attrs.formId + '" ' + required + '>' +
  21. '</div>' +
  22. '</div>';
  23. } else {
  24. //for other add different html
  25. }
  26. element.replaceWith(htmlText);
  27. }
  28. };
  29. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement