I'd like to create a directive to dynamically render widgets, each with
it's own template and controller.
Suppose we have an array of widgets created at runtime:
[
{
controller: 'TweetWidgetCtrl',
template: 'tweets.tpl.html'
},
{
controller: 'FacebookWidgetCtrl',
template: 'facebook.tpl.html'
}
]
I want to render them like so:
<widget ng-repeat="widget in widgets" controller="widget.controller"
template="widget.template"></widget>
So far I've tried:
1. Using an attribute to specify the directive *controller *(@) but this
only works with text values and doesn't support 2 way binding.
2. Dynamically building the template in a link function and compiling the
directive contents which results in only one of the widget controllers
being instantiated.
3. Using a compile function to set *ng-controller* on the element but
couldn't get this to work.
Any help would be greatly appreciated.
Ben
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.