Hi all,
Im trying to get the x & y coords of the button in my Ionic View page.
This is my HTML:
<button #data class="drag-button" draggable="true" (click)="show()" data-id="{{ btn.id }}" [style.background-color]="btn.kleur">
{{ btn.artikelnummer }}
</button>
But now when I click on the button it send its to my show function in home.ts
That contains the following code:
show(){
console.log(this.element.nativeElement);
console.log('left ' + event.srcElement.nativeElement.offsetLeft);
console.log('top ' + event.srcElement.nativeElement.offsetTop);
}
At top of my Home.ts I got:
import { Directive, Component, ElementRef, ViewChild } from '@angular/core';
And in my constructor I got:
constructor(private http: Http, private element:ElementRef, public navCtrl: NavController) {
But the problem now is that If I click on the button.
the nativeElement is returning the following:
But it has to be in the first console.log:
<button #data class="drag-button" draggable="true" (click)="show()" data-id="{{ btn.id }}" [style.background-color]="btn.kleur">
{{ btn.artikelnummer }}
</button>
And beside of that I’m not receiving any offsetLeft / Top coords.
I hope some one can help me out.
Thanks in advance.