Reputation: 2417
I'm having trouble figuring out how to programmatically instantiate directives. For example, in the tabbed panels example, suppose I want to have a function to "Add a new tab" in the parent tabs directive; how should the tabs directive instantiate a new pane directive and add it to the DOM?
Upvotes: 1
Views: 223
Reputation: 9700
I would have a scope variable containing the list of panes you want to display, put the HTML for a single pane inside an ng-repeat
and have the "add a new tab" function simply add another object to the list of panes; Angular's two-way binding would have the list of DOM elements inside the ng-repeat
updated upon updating the list.
Upvotes: 3