angularjs - ng-click inside cell template does not trigger function in controller -
angularjs - ng-click inside cell template does not trigger function in controller -
i have created plunker here: http://plnkr.co/edit/zgqouwzxguef13lx48ip?p=preview
when click in cell of ui-grid in day view nil happens. expected test function executed , alert shown text 'test' not case.
what going on wrong here?
thats html cell template of ui-grid 3.0 latest release:
html
<div ng-click="test()" ng-switch="row.entity[row.grid.columns.indexof(col)].isperiod"> <div ng-switch-when="true"> <tabset> <tab> <tab-heading> <i class="glyphicon glyphicon-book"></i> </tab-heading>period id: {{ row.entity[row.grid.columns.indexof(col)].id}} </tab> <tab select="alertme()"> <tab-heading> <i class="glyphicon glyphicon-bell"></i> </tab-heading> {{row.entity[row.grid.columns.indexof(col)].content}} </tab> </tabset> <!-- periodtemplate --> </div> <div ng-switch-when="false"> <div>hello empty template</div> </div> <!-- emptyperiodtemplate --> </div>
controller:
'use strict'; angular.module('projectplanner').controller('dateplannerdaycontroller', function ($scope, $state) { var columnheaderdates = ['col1','col2','col3','col4','col5','col6','col7'] $scope.columns = createcolumnheaders(columnheaderdates); var info = [{isperiod: true, id: 10, rownumber: 1},{isperiod: false, id: 11, rownumber: 2}] $scope.test = function() { alert('test'); }; $scope.gridoptions = { rowheight: 200, data: data, enablesorting: false, enablecolumnmenu: false, columndefs: $scope.columns, onregisterapi: function (gridapi) { $scope.gridapi = gridapi; $scope.gridapi.core.addrowheadercolumn( { name: 'rowheadercol', displayname: '', width: 100, celltemplate: '<div>row header template</div>' }); } }; function createcolumnheaders(columnheaders) { var columndefinitions = []; (var = 0; < columnheaders.length; i++) { var column = { name: columnheaders[i], celltemplate: 'lessonplanner.day.celltemplate.html', field: + 'x' } columndefinitions.push(column); } homecoming columndefinitions; } });
this page kept popping in searches , managed miss solution in comments. summarize, need utilize externalscopes. see angular ui-grid events in cell header not firing , http://ui-grid.info/docs/#/tutorial/305_appscope
angularjs angular-ui-grid
Comments
Post a Comment