gulp-inline-ng2-template
gulp-inline-ng2-template copied to clipboard
Variable in paths
Hi!
I created a dynamic module factory function which produces components on-the fly using my convention. It looks like:
function createComponent() {
let type = this.widget.type;
let path = './'+type+'/'+type;
@Component({
selector: 'widget-'+type,
moduleId: module.id,
templateUrl: path+'.html',
styleUrls: [path+'.css']
})
class CreatedComponent extends widgetRepo[type] { };
return CreatedComponent;
When I try to build prod - I'm using mgechev/angular2-seed - this plugin result the error: 'path is not defined'. As I see it only works on the lines of the source code and won't executes anything at all. So I don't think its possible to use paths contains vars. Am I right?
How should I solve this issue? I have many similar - and convetionally structured - widgets so I don't want to copy-paste component declaration into all of them. My createComponent function is part of my dynamic widget loader concept so it wasn't created only for the component declaration part.
I'm having the same issue. I'm reusing component metadata among multiple components, so my decorators basically just read @Component(variable_containing_the_metadata)
or
@Component(Object.assign({}, variable_containing_the_metadata, {
/* some component-specific modifications to the metadata */
})
This issue basically means that I have to copy & paste around the metadata that is common to all my components – which not only is a major PITA but also leads to unmaintainable code.