I have two link which is displaying two different images on click of respective link.first behaviour is fine but when again I click on selected link, image is displaying correct but hover is moving to another link. I mean its displaying second link as selected. here is what I did up to now.
Can someone help what I am doing wrong?
this.toogleClick
is true
loadingImg(folder) {
this.toggleClick = !this.toggleClick;
this.meta
.getToken(
"images",
this.imgName.ReportJobId,
(folder == "input" ?
this.imgName.UniquePhotoName :
this.imgName.UniquePhotoName
.replace(".JPG", ".png")
.replace(".jpg", ".png")),
folder
)
.subscribe(data => {
this.imgSrc = this.someurl(data);
}, () => {
this.imgSrc = "assets/images/image.jpg";
});
}
<ul class="result__image--tabslist">
<li class="result__image--tab left left__tab" (click)="loadImg('output')">
<span class="result__tab--txt" [ngClass]="toggleClick?'selected':''">
Scan
</span>
</li>
<li class="result__image--tab left" (click)="loadImg('input')">
<span class="result__tab--txt" [ngClass]="toggleClick?'':'selected'">
Original
</span>
</li>
</ul>
You can try with
[class.selected]="toggleClick"
instead of
[ngClass]="toggleClick?'':'selected'"
This way the selected
class is applied only if toggleClick
is true.