constructor(
public templateHeaderRow = 'DefaultTableHeaderTemplate',
public templateBodyRow = 'DefaultTableRowTemplate',
private templateBase = _templateBase) {
require([this.templateBase + templateHeaderRow + '.html', this.templateBase+ templateBodyRow + '.html'], () => console.log('fdsfdsdfsf'));
}
Then I am calling it like this: log = new ListViewBase(undefined,'LoggingTableRowTemplate');
It seems a little stupid with the (undefined,'. Can anyone who can suggest a different design?
What would be nice, would be something like in C# where I can do (parametername:value, another:value2), and the order doesn't matter for the optional parameters. Haven't found anything like that in typescript though.
Update
Alternative I am doing this:
public templateHeaderRow = 'DefaultTableHeaderTemplate';
public templateBodyRow = 'DefaultTableRowTemplate';
private templateBase = _templateBase;
constructor(configuration? : ListViewBaseConfiguration) {
if (typeof configuration !== "undefined") {
if (typeof configuration.templateBase !== "undefined")
this.templateBase = configuration.templateBase;
if (typeof configuration.templateBodyRow !== "undefined")
this.templateBodyRow = configuration.templateBodyRow;
if (typeof configuration.templateHeaderRow !== "undefined")
this.templateHeaderRow = configuration.templateHeaderRow;
}
require(['template!' + this.templateBase + this.templateHeaderRow + '.html',
'template!' + this.templateBase + this.templateBodyRow + '.html']);
}
But I have to write alot more code to get the behavior that some parameters can be set and others not.