This is a migrated thread and some comments may be shown as answers.

Angular directive: access kendo widget instance

1 Answer 300 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Koen Van Wijmeersch
Top achievements
Rank 1
Koen Van Wijmeersch asked on 15 Sep 2014, 07:59 PM
Hi all,

I'm trying to access the instance of a kendo ui widget from within an angular directive.
To do so, I'm using kendo's widgetInstance function.
However, in angular's link function, the widget is not yet created (line 3).

1.link: (scope:, element, attrs) =>{
2.    // widget is undefined
3.    var widget = kendo.widgetInstance(element, kendo.dataviz.ui);
4.    scope.$on('kendoWidgetCreated', (r, t) =>{   
5.        // widget is defined, how to check that widget2 === element?
6.        var widget2 = <kendo.dataviz.ui.Chart>kendo.widgetInstance(element, kendo.dataviz.ui);
7.    });
8.}

I've read about the kendoWidgetCreated event; when using this, there are 2 issues (line 7):
  • the event is fired for every widget that is created within the scope; how to check that element === widget without depending on id's?
  • when using an isolated scope , the event is not fired on this isolated scope
Is there a better way to access the widget instance from within a directive?

Thanks for your time,
Koen

1 Answer, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 17 Sep 2014, 08:21 AM
Hi,

the easiest way to access the widget instance would be via the following directive syntax. Apart from that, the widget features an element field (a jQuery object), which may be used for the comparing you refer to. 

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
General Discussions
Asked by
Koen Van Wijmeersch
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Share this question
or