I am attaching element inside template dynamically by user click, this way:
this.optionValue = [];
youClickMe(){
var moreput = '';
moreput += '<select">';
moreput += '<option *ngFor="let lup of optionValue">{{lup.name}}</option>';
moreput += '</select>';
var pElement = document.querySelector('.somewhereyoubelong');
pElement.insertAdjacentHTML('beforeend', moreput);
}
However the {{lup.name}} doesn't print the actual value but as how it is typed there. How to make it works? Anybody?
UPDATE:
I've tried with this way, but still it's said that
const templating = '<p *ngFor="let sizeCat of sizeCategoryBySubCategory" [value]="sizeCat.id">{{sizeCat.name}}</p>';
const tmpCmp = Component({template: templating})(class {});
const tmpModule = NgModule({declarations: [tmpCmp]})(class {});
this._compiler.compileModuleAndAllComponentsAsync(tmpModule).then((factories) => {
const f = factories.componentFactories[0];
const cmpRef = f.create(this._injector, [], null, this._m);
//cmpRef.instance.testText = 'B component';
cmpRef.instance.sizeCategoryBySubCategory = [
{ id:1, name: 'a'},
{ id:2, name: 'b'},
];
this._container.insert(cmpRef.hostView);
});
Property binding ngForOf not used by any directive on an embedded template