angularjsangular-uiangular-ui-gridcelltemplate

Why can't I call a function from within a ui-grid cell-template


I have a cellTemplate that's supposed to make a row editable when clicked. Works so far. However when this is done, also a function should be called, which just isn't happening:

colDef:

cellEditableCondition: ($scope) => $scope.row.editable

what I tried in cellTemplate:

ng-click="row.editable = true;" //works
ng-click="row.editable = true; console.log('WTF?')" //works, no log
ng-click="console.log('WTF?'); row.editable = true;" //works, no log
ng-click="console.log('WTF?')" //no log either

When you click the button, the cells become editable, just as intended. But nothing's printed to the console . And I can't seem to figure out why. Is there something I'm missing? How do I call a function from within a cellTemplate?


Solution

  • console belongs to the javascript window object. It is not inside angular's scope. If you want to use it in an angular template, in your controller add this:

    $scope.console = window.console;