I've got this object in Angular.
$scope.columns = {
workspace: {
title: "Workspace",
type: "workspace",
activities: []
},
alerts: {
title: "Alerts",
type: "alert",
activities: []
},
main: {
title: "Main Feed",
type: "main",
activities: []
}
};
And in my HTML I need to loop through it to dynamically create a series of columns in my app (think something like Trello)
Each type
is a reference to a custom directive.
I'm trying to figure out the best way to place my directives.
Based on this data, is the code below an appropriate way to handle dynamically creating these?
<div ng-repeat="(key, obj) in columns">
<div ng-switch on="obj.type">
<workspace-feed ng-switch-when="workspace" />
<alert-feed ng-switch-when="alert" />
<main-feed ng-switch-when="main" />
<filter-feed ng-switch-when="filter" />
</div>
</div>
I'd love to be able to do something like... <{{obj.type}}-feed />
but I'm not sure if this is valid, or if there's a better way to create this.
Thoughts are much appreciated!