I am using jquery kendo ui grid and from that edit button i am trying to call angular2 method. My setup is simple:
export class UserComponent implements OnInit {
constructor( @Inject(UserService) public userService: UserService, @Inject(FormBuilder) public fb: FormBuilder) {
...
}
edit():void{ }
onInit() {
$("#grid").kendoGrid({
....
click: function () {
// Call angular2 method of the current instance
});
}
}
It's working code the only issue is this. I can call the angular2 method by just stating
click:this.edit
or
click: function () {
UserComponent.prototype.edit()
});
but in both case the method is not from the current instance. So in this case i cannot make use of the http service or any local variable or methods inside edit
Try something like this
click: function () {
this.edit();
}).bind(this);
or
var self = this;
$("#grid").kendoGrid({
click: function () {
self.edit();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With