Angular 2 - Jquery |使用鼠标位置添加样式 (top/left)

Angular 2 - Jquery | Adding styles (top/left) with a mouse position

我正在寻找一种在 Angular 2 中的特定位置(鼠标事件 x/y)添加 div 组件的方法。

https://jsfiddle.net/lennartquerter/w2c7uqw6/

this.xPos = xPos;
this.yPos = yPos;

我将位置传递到我的拒绝 class,但我不知道如何从中制作样式?我检查了 angular 文档,但我只能设置布尔值并固定 css 值/classes。我想做这样的事情:

[style]="rejectPosition"

this.rejectPosition = "left: " + this.xPos + "px ; top: " + this.yPos + "px;"

但这是不可能的。 有 Angular 2 方法吗?

我找到了一种没有拒绝组件的方法,它只是将其样式设置为与 jQuery 内联,但我不喜欢这种方法。

[style.left.px]="xPos" [style.top.px]="yPos"