DevExtreme Angular - Handle Events

IMPORTANT
According to Stack Overflow Trends, MVVM frameworks such as Angular, Vue, and React became more popular than Knockout in recent years. DevExtreme will continue to support Knockout but we recommend that you use one of these frameworks in your new projects.

You can subscribe to an event using a configuration option. All event handling options are given names that begin with on.

JavaScript
var viewModel = {
    menuInstance: {},
    menuOptions: {
        // ...
        onItemClick: function (info) {
            // Handles the "itemClick" event
        },
        onInitialized: function (info) {
            // Saves the widget instance
            viewModel.menuInstance = info.component;    
            // Handles the "initialized" event
        }
    }
};

ko.applyBindings(viewModel);

View Demo

See Also
  • API Reference.WidgetName.Events, for example, API Reference.Menu.Events