You can put this:
<input {{p.dir}} ngmodel="p" />
also in the directive. You can build this HTML string in JavaScript and attach it to the DOM. And you will also need to compile the resulting element using the $ compilation service so that the dynamic directives are compiled.
Some kind of dummy code example (not tested, but should look something like this):
app.directive('dynamicInput', function($compile){ return { link: function(scope, element){ var htmlString = '<input ' + scope.field.dir + ' ng-model="p"/>'; element.replaceWith(htmlString); $compile(angular.element(element))(scope); } }
});
More details here .
source share