I was trying to create an image gallery with Angular 4.The logic behind this is to add a Cascading Style Sheet (CSS) class to the selected image that will show a red border on t
Here is a plunker showing how you can use it with the ngClass directive.
ngClass
I'm demonstrating with divs instead of imgs though.
div
img
Template:
TS:
export class App { selectedIndex = -1; setSelected(id: number) { this.selectedIndex = id; } }