angularjskendo-uiangular-kendo

How Angular detects Kendo on-click events?


Can someone please explain the logic behind angulars ability to detect Kendo's on-click events inside the scope without ng-model on the button?

<kendo-button on-click="clickWithoutNgModel()">Button</kendo-button>

$scope.clickWithoutNgModel = function () {
        alert("Clicked without using ng-model on the button");
} // this works - how?

Solution

  • It's the other way around, actually. AngularJS doesn't detect the click event, but the Kendo widget calls the AngularJS controller method.

    When creating the Kendo widgets, the Kendo code will bind the clickWithoutNgModel function as an event handler for the click event in the Kendo Button widget. For that, it uses $scope.$eval to get the function from the scope and then calls it when the click event is triggered.