I'm trying to dynamically add components to my @Component template the components are populating but the tool bar does not change when I change the "buttonstring" variable.
I have a component..
@Component({
selector: 'map-toolbar-action',
template:'<p style="position: absolute;z-
index:5000">' + mapValues.buttonString +
'</p>',
styleUrls: ['./map-toolbar-
action.component.scss']
})
export class MapToolbarActionComponent
implements OnInit {
constructor() {
mapValues.buttonString =
mapValues.arrayToString(mapValues.buttons);
}
ngOnInit() {
}
}
I have a singleton with these elements...
public static buttonString = "<component1></component1><component2></component2><component3></component3>";
I was hoping that I could then change buttonString to add, subtract or completely replace the list of components and the toolbar would update.
buttonString = "<component2></component2><component3></component3>";
buttonString = "<component1></component1><component2></component2><component3></component3><component4></component4>";
buttonString = "<componentA></componentA><componentB></componentB><componentC></componentC>;
and that would in-turn update the components to the template but it's not working like that...how can I accomplish this?
Any help is greatly appreciated!!
ComponentFactoryResolverto load components dynamically angular.io/guide/dynamic-component-loader