make custom component for input with label
[angular-drzb] / app / js / directives.js
index 9fc16cc..f447c7e 100644 (file)
@@ -8,4 +8,12 @@ angular.module('myApp.directives', []).
     return function(scope, elm, attrs) {
       elm.text(version);
     };
-  }]);
+  }]).
+  directive('myInput', function() {
+    return {
+               restrict: 'C',
+               compile: function(element, attrs) {
+                       element.replaceWith('<div class="'+attrs.class+'"><label for="'+attrs.ngModel+'">' + attrs.placeholder + '</label><input type="'+ ( attrs.type || 'text' ) +'" name="'+attrs.ngModel+'" ng-model="' + attrs.ngModel + '" ng-required="' + attrs.ngRequired + '" placeholder="' + attrs.placeholder + '" /></div>');
+               }
+    };
+  });