I have a problem very similar to the one asked here How to add a component programatically in Angular.Dart?. I am using Angular Dart and have a task bar component that I want to fill with a list of task components. I would like a new task component to be added when a button is pressed. Here is the code I currently have.
task_bar_component.html
<ul id="taskList" class="taskBar-items">
<li ng-repeat="task in taskbarCmp.tasks">
{{task}}
</li>
</ul>
task_bar_component.dart
@Component(
visibility: Directive.CHILDREN_VISIBILITY,
selector: 'taskbar',
templateUrl: '../lib/components/taskbar_component.html',
publishAs: 'taskbarCmp',
useShadowDom: false)
class TaskBarComponent {
List tasks;
TaskBarComponent() {
tasks = new List();
}
void addTask() {
var newTask = new TaskComponent();
tasks.add(newTask);
}
}
task_component.dart
@Component(
visibility: Directive.CHILDREN_VISIBILITY,
selector: 'task',
templateUrl: '../lib/components/task_component.html',
publishAs: 'taskCmp',
useShadowDom: false)
class TaskComponent {
bool _collapsed = true;
int _lopCount = 0;
int _geoCount = 0;
int _volume = 1;
String id;
TaskComponent() {
Collapse.use();
}
}
This code currently adds an "Instance of 'TaskComponent'" to the html on the button click, but it does not contain the actual task_component.html. I tried using the ShadowRootAware from the solution in the previous question but am not sure how onShadowRoot gets called when the button is pressed. I also tried to use the directive solution that was suggested in that post as well and had the same issue, not being able to create the component when the button is pressed. ANy suggestions would be greatly appreciated.