0

Have table and if I mousemove on columns need to get column data as tooltip, tried below code and getting tooltips. But if we hover on dropdown all options are coming in tooltip. Could you please help me how to get only selected option in tooltip.

  ngOnInit(): void {
    $(document).on("mousemove", "tr td", function () {
      var colVal = $(this).text();
      $(this).prop("title", colVal);
    }); 
  }

Demo

1 Answer 1

1

Instead of using jquery(Jquery is not recommended in angular), directly bind title in HTML itself

<tr *ngFor="let person of persons;let i = index;">
   <td>
      <input [(ngModel)]="person.check" [checked]="isChecked" type="checkbox" class="checkboxCls" name="id" >
   </td>
   <td title="{{person.id}}">{{ person.id }}</td>
   <!-- Bind selected option here -->
   <td title="{{person.test}}">
      <select [disabled]="!person.check?true:null" [(ngModel)]="person.test" title="{{person.test}}" (change)="selected(person.test)">
      <option *ngFor="let prod of ProductHeader" [value]="prod.name" >{{prod.name}}</option>
      </select>
   </td>
   <td title="{{person.test}}">{{ person.test }}</td>
   <td title="person.firstName">{{ person.firstName }}</td>
   <td title="{{person.lastName}}">{{ person.lastName }}</td>
</tr>
Sign up to request clarification or add additional context in comments.

1 Comment

Hi @Sameer, Could you please suggest me below question, stackoverflow.com/questions/67549092/…

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.