I've got the basic form input directive that sets up some form elements base on name:
angular.module('myApp').directive('formInput', function () {
return {
restrict: 'A',
require: '^form',
link: function (scope, element, attributes, form) {
var input, name;
input = element[0].querySelector('input, textarea, select');
name = input.getAttribute('name');
// ...
// do stuff with input, name, form etc.
}
};
});
In my HTML I do some simple DOM setup and it does the trick.
<div form-input>
<input type="text" name="myElement"/>
</div>
The problem comes when I start having dynamic names, i.e.
<div form-input>
<input type="text" name="{{ getDynamicName(element) }}"/>
</div>
The dynamic name is not evaluated prior to getting into my directive. Is there a way to tackle this issue?
P.S. Given the decorative nature of the directive I prefer not to use isolate scopes.