# Angular template for a dropdown menu

I'm ashamed to ask such an elementary question but I tried to DRY up this template a couple ways and couldn't come up with anything I was satisfied with. Can you help?

  %ul.dropdown-menu(aria-labelledby="single-button" role="menu" uib-dropdown-menu)
%a(href="/legal-forms/admin/document_templates/{{ documentTemplate.id }}/preview" document-template-preview="true" id="documentTemplate.id") Preview
%a(href=true ng-click="copy(documentTemplate)") Copy
%a(href=true ng-click="delete(documentTemplate)") Delete

• What templating language/framework is it written in/with? – Igor Soloydenko Nov 29 '17 at 7:46

I think this is solid code. All I can think of is a repeat pointing to an array in the controller. I do this on some of our web apps that have high-freq of changes to menu items.

I don't know if this would really be a good refactor otherwise as it just abstracts away more of the template but it definitely DRY's it up.

BTW I'm not familiar with that templating lib so I apologize if there are any problems with the syntax.

template

 %ul.dropdown-menu(aria-labelledby="single-button" role="menu" uib-dropdown-menu)
%a(
href={{ ( item.is_path ) ? item.pathLocation : true }}
ng-click={{ item.clickTrigger }}
ng-hide={{ ( item.can_hide ) ? "documentTemplate.parent_id" : "" }}
)
{{item.text}}


somewhere in the controller

doc_dropdown = [
{
is_path: true,
text: "Edit",
click_trigger: null,
can_hide: false
},{
is_path: true,
text: "Create Document",
click_trigger: null,
can_hide: false
},{
is_path: true,
text: "Preview",
click_trigger: null,
can_hide: false
},{
is_path: false,
pathLocation: null,
text: "Copy",
click_trigger: "copy(documentTemplate)",
can_hide: true
},{
is_path: false,
pathLocation: null,
text: "Delete",
click_trigger: "delete(documentTemplate)",
can_hide: false
},
];