4

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

2
  • all Angular methods are JavaScript, so your question title doesn't even make sense. Commented Nov 3, 2015 at 3:10
  • Yes all angular methods are javascrupt but my title "angular2 method " by this i mean the method of an instance. because if you just call this.edit it wont execute the method from the current instance. Commented Nov 3, 2015 at 4:19

1 Answer 1

7

Try something like this

click: function () {
   this.edit();
}).bind(this);

or

var self = this;
$("#grid").kendoGrid({

   click: function () {
     self.edit();
   });
Sign up to request clarification or add additional context in comments.

Comments

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.