2

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>

2 Answers 2

1

You can try with

[class.selected]="toggleClick"

instead of

[ngClass]="toggleClick?'':'selected'"

This way the selected class is applied only if toggleClick is true.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi. style is not changing. both are displaying as selected.
You put the same class directive on both images. Of course they both have selected class.
1

You can try:

[class]="toggleClick?'selected':''"

or,

[ngClass]="{'selected': toggleClick}"

or,

[class.selected]="toggleClick"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.