Here is a simplified directive that hardcodes <br>
HTML:
<p hidden-repeat="lines"></p>
app.directive('hiddenRepeat',function($parse){
return {
link: function(scope, elem, attr){
var data = $parse(attr.hiddenRepeat)(scope);
if(data){
for (var i=0;i< data.length;i++){
elem.append(data[i]+ "<br />");
}
}
}
};
});
See in action: http://plnkr.co/edit/Y8eahPYmBr5ohbWCInde?p=preview
This solution allows you to specify a directive in an attribute (in this case, hidden repetition). Using the version of the attribute of the directive, you can specify what a packaging element is (in this case, a paragraph).
source
share