My Angular2 application includes the following code in app.component.ts:
...
export class AppComponent {
// themes array
readonly themes = ['assets/default-theme.css', 'assets/test-theme.css', ...];
// theme setter
setTheme(href: string) {
setThemeLinkHref(href);
console.log('The theme has been updated to: ' + href);
}
...
}
In the app.component.html template, I have the following code:
...
<button (click)="setTheme(themes[0])">Default</button>
...
When using this approach, I notice that 'undefined' is logged as the theme's href:
The theme has been updated to: undefined
Is there a way to correctly pass a specific item from an array as an argument to a function?