I have one controller in angularJs(1.6) which is using ui-grid. Problem is there is one cell template. I want to get its value from a function. I have tried creating a function and tried to call it using grid.appScope.function. But it did not work. I have tried to put my function with vm also. But to not avail.
Could anyone please help me with this?
Here is my controller code:
(function () {
'use strict';
define([
'angular'
], function (angular) {
function SelectToolController($scope, $timeout, $filter, uiGridConstants) {
var vm = this,
_gridApi,
_cellTemplate,
_columnDefs,
_starRatingTemplate,
_starRatingColumn,
_starEnable;
};
_starRatingTemplate = [
'<div class="opr-star-rating" >',
'<opr-star-rating rating-percentage="getRating()">',
'</opr-star-rating>',
'</div>'
].join('');
//this func need to be called from _starRatingTemplate
vm.getRating = function(){
return 10;
}
function gridInitialized(gridApi) {
_gridApi = gridApi;
}
});
I am posting answer of my own query.
Below setting in cellTemplate worked for me:
_starRatingTemplate = [
'<div class="opr-star-rating" >',
'<opr-star-rating rating-percentage="+vm.getRating()+">',
'</opr-star-rating>',
'</div>'
].join('');