N.Zukowski
N.Zukowski

Reputation: 601

AngularJS UI Grid cell template using TYPESCRIPT

Before you answer my question please consider that I am using AngularJS 1 with TYPESCRIPT.

Does any body know how to bind a controller function to cell template like asked in this link using Angular UI Grid?

I have got a very similar situation, where I define custom cell template containing buttons and try to bind the ng-click directive to a function in the controller?

So I just have something like this:

Component template:

<div id="grid1" ui-grid="$ctrl.gridOptions" class="grid" external-scopes="ctrl"></div>

Component controller (just some code snippets):

ctrl = this;

exampleFunction() {
    console.log("Example function called.");
}

actionsCellTemplate = 
            '<btn class="btn btn-default action-button" ng-click="getExternalScopes().exampleFunction()">' +
                '<i class="icon-blue"><b>...</b></i>' +
            '</btn>';

columnDefs: [ { displayName: '', field: 'actions', enableColumnMenu: false, cellTemplate: this.actionsCellTemplate } ]

I DO NOT get any errors in the browser console.

Upvotes: 1

Views: 722

Answers (1)

nocodename
nocodename

Reputation: 1266

External scopes are no longer supported in ui-grid since RC 19. https://github.com/angular-ui/ui-grid/blob/master/CHANGELOG.md#breaking-changes

getExternalScopes() function is removed. Use grid.appScope instead. external-scopes attribute is removed. Use gridOptions.appScopeProvider to assign values other than $scope.$parent to appScope

Upvotes: 1

Related Questions