JSFiddle - React, Tailwind, and code Playground
by cherniv
HTML
<div ng-app='test' ng-controller='testCtrl'>
<label for="test1">Testlabel 1</label><br>
<input id="test1" type="text"></input><br>
<my-input id="test2"
label="Testlabel 2"
placeholder="enter somthing"
text="testVar"></my-input><br>
<span>{{testVar}}</span>
</div>
JavaScript
angular.module('test', [])
.directive('myInput', function() {
return {
restrict: 'E',
template: '<label for={{id}}>{{label}}</label><br>' +
'<input id={{id}} type="text" ' +
' placeholder={{placeholder}} ng-model="text" />',
scope: {
id: "@",
label: "@",
placeholder: "@",
text: "="
},
link: function(scope,el,attrs){
el.removeAttr("id")
}
}
})
.controller('testCtrl', ['$scope', function($scope) {
$scope.testVar = 'testing';
}]);