Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grid.appScope not working for ui grid angular js

Wanted to access a function from my custom cellTemplate. For that, i am using grid.appScope. Following is the code :

$scope.test = function(){
    alert('a');
  };

columnDefs: [
      { field: 'name',      displayName: 'Name', cellTemplate: '<div ng-click="grid.appScope.test()">ABCDEFGH</div>' },
      { field: 'id',      displayName: 'ID' }
]

Can anyone tell me what is the issue with the above code ?

like image 319
Rohan Kangale Avatar asked Aug 10 '26 19:08

Rohan Kangale


1 Answers

I have face the same problem and able to resolve it in my case we have made the grid as directive in that it is not able to recognize the test function. In order to do that just use $parent scope

like this

grid.appScope.$parent.test();
like image 182
Surya Prakash Tumma Avatar answered Aug 13 '26 12:08

Surya Prakash Tumma