Continuing from the previous question, which can be found here, I have an additional query that I felt warranted a separate post.
The link provided above demonstrates how to obtain a grid instance in Angular, credit to Lars for that.
Building upon the example in the previous question, I have now introduced the following directive:
<body>
<div data-ng-app="app">
<div data-ng-controller="Grid as vm">
<div id='aa'>
<div pckendo id='bb' kendo-grid='grid'
k-options="vm.options"></div>
</div>
</div>
</div>
</body>
In addition, I added the following code in the .js file:
angular
.module("app", ["kendo.directives"])
.controller("Grid", Grid)
.directive('pckendo', PCKendo);
....
function PCKendo() {
function link(scope, element, attrs) {
var instance = element;
var vm = scope.vm;
vm.msg = "";
var grid = scope.grid;
}
return {
link: link
}
You can view the complete example here.
Instead of fetching the instance in the controller, my goal is to retrieve it via a directive (as I believe this is a more appropriate place for event handling, etc).
I've attempted various approaches within the directive but haven't succeeded in obtaining the grid instance. Any further guidance on this matter would be highly appreciated.
Thank you in advance!