Angular directive: access kendo widget instance

2 posts, 0 answers
  1. Koen Van Wijmeersch
    Koen Van Wijmeersch avatar
    6 posts
    Member since:
    Dec 2009

    Posted 15 Sep 2014 Link to this post

    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

  2. Petyo
    Admin
    Petyo avatar
    2444 posts

    Posted 17 Sep 2014 Link to this post

    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!
     
Back to Top