I seem to be having a problem with recursively updating a list of nodes. The nodes get created as elements using promises so they complete rendering themselves.
export class DrawingService { drawWidget (nodeData, parent) { return this.componentsFactory.get(nodeData.component, nodeData, parent); } drawWidgetAndChildren(node, parentElement) { this.drawWidget(node, parentElement).then((element) => { this.drawWidgets(element); }); } drawWidgets(parentElement) { for (var node of this.nodes) { if (node.parentId == parentElement.attr("id")) { this.drawWidgetAndChildren(node, parentElement); } } } } export function componentsFactory ($compile, $rootScope){ 'ngInject'; return { get: function (component, options, parent) { return new Promise( (resolve,reject) => { let scope = $rootScope.$new(); options.component = component; options.resolve = resolve; scope.options = options; let element = angular.element("<" + component + " options='options' ></" + component + ">"); element.attr("id", options.id); let compiledElement = $compile(element)(scope); parent.append(compiledElement); }); } }; The componentsFactory creates a widget element which populates itself with data and then assigns a resolve => this.options.resolve(this.element); At the time the widget resolves, its data looks correct. However, when the drawWidgetAndChildren then statement returns, the element in the then(element) contains the original value before it gets populated. Looks like something gets overwritten in memory. Would anyone have an idea what i'm doing wrong or is this an angular issue ? } -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To post to this group, send email to angular@googlegroups.com. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.