I'd like to use a configuration object to display a list. The problem is that this list has different types of elements it can contain: item, divider, and subheader.
A simple configuration for this list might be:
var list = [
"item",
"item",
"divider",
"subheader",
"item",
"item"
];
How do I write an ngRepeat
attribute that would output something like this:
<md-menu-content>
<md-menu-item>...</md-menu-item>
<md-menu-item>...</md-menu-item>
<md-menu-divider></md-menu-divider>
<md-subheader>...</md-subheader>
<md-menu-item>...</md-menu-item>
<md-menu-item>...</md-menu-item>
</md-menu-content>
I'm not even sure this is possible. Looking at the documentation for ngRepeat, it can only be used as an attribute, so something like <ng-repeat>...</ng-repeat>
is not an option. md-menu-item
, md-menu-divider
, and md-subheader
also have to be elements as they're part of Angular Material and even if list item and the subheader aren't specifically restricted to being an element (unlike the divider), their CSS styles are written to be for elements only.
I've also played around with ngRepeatStart
, but that's an alternative to ngRepeat
, and they, as far as I can see, cannot be used together so that ngRepeat
would be one level above ngRepeatStart
.