I'm developping an app on Angular 2 and in this app I need to change dynamically some attributes inside @Component decorator. Here is my code :
function componentFactory (directives: any[], template: string) {
let annotations = Reflect.getMetadata('annotations', ComponentBase)
annotations[0].directives = directives
annotations[0].template = template
let metadata = new ComponentMetadata(annotations)
Reflect.defineMetadata('annotations', [ metadata ], ComponentBase)
return ComponentBase
}
The problem is that when I use it (with a ComponentResolver) I get this error : "Component 'ComponentBase' must have either 'template' or 'templateUrl' set.".
Do you have any suggestions ?
Thank you :)