I managed to load an html dynamicallyin one component using ngTemplateOutlet.
My code is like this:
@Component({
selector: 'nav-menu',
template: `<template [ngTemplateOutlet]="getTemplate()"></template>
<template #displayTmpl>
<td>petko</td>
<td><button>Edit</button></td>
</template>
<template #editTmpl>
<td><input type="text" value="stanko" /></td>
<td><button>Save</button><button>Cancel</button></td>
</template>
`
})
export class NavMenu {
@ViewChild('displayTmpl') displayTmpl : TemplateRef<any>;
@ViewChild('editTmpl') editTmpl: TemplateRef<any>;
getTemplate() {
return this.displayTmpl;//this.displayTmpl, this.editTmpl
}
constructor(private authService: AuthService) { }
}
However I would like for the templates not to be included here, I would like displayTmpl and editTmpl to be two separate .html documents. How would I do that?