Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
171 views
in Technique[技术] by (71.8m points)

html - click event not working in angular 8 in mobile device

A click event is not working on mobile devices. But it's working fine on other devices. If anyone knows please help to find a solution.

app.component.html:

    <ul class="resp-tabs-list">
        <li *ngFor="let topic of topicsList;let i=index;"(click)="getContentList(topic)" >
            <i class="fa fa-book"></i> &nbsp;{{topic.name}}
            <div *ngIf="topic.obtainMarks> 0" style="color: black">Competency level : {{topic.obtainMarks}} %
            </div>
        </li>
   </ul>

app.component.ts:

getContentList(topic: Topics): void {
  console.log(topic);
}
question from:https://stackoverflow.com/questions/65932308/click-event-not-working-in-angular-8-in-mobile-device

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try using ng-click instead of (click). I hope it will work.

<li *ngFor="let topic of topicsList;let i=index;" ng-click="getContentList(topic)">

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...