I would like to know how to dynamically add attribute or property to a specific mark-up in my template. I have my directive like this:
app.directive('myDirective', function() { return { restrict: 'A', template: '<div><label>Label: </label><input id="my-id" type="text" attr="attrValue"/></div>' }; }); Question 1: How would I place attr="attrValue" specifically on input element / mark-up?
Suppose I want to write:
<my-directive ... readonly></my-directive> Question 2: How can I pass readonly property to the input element in the template?
app.directive('myDirective', function() { return { restrict: 'A', template: '<div><label>Label: </label><input id="my-id" type="text" readonly/></div>' }; });
<label>ed input and ended up doing quite acompilefunction for it. Any way, the solution for me was to create a directive that wraps the<input/>element I wanted to modify like<labeled-input><input ... /></labeled-input>