无法在cellTemplate中访问ui-grid

时间:2017-11-21 12:12:31

标签: angularjs angular-ui-grid ui-grid

我正在尝试在角度框架内的ui-grid中创建一个具有不同格式的列。

columnDefs: [{
                    name: 'Column', width: 300, visible: true, cellTemplate: '<a href="modelremote:{{ grid.getCellValue(row, col) }}">{{ grid.getCellValue(row, col) }}</a>'
                }]

但是,当代码运行时,我收到以下错误

jinja2.exceptions.UndefinedError: 'grid' is undefined

1 个答案:

答案 0 :(得分:0)

事后看来,这里的解决方案就像问题一样明显。错误消息指向jinja2,这是我用来为我的页面提供服务的模板引擎。

角度和jinja2都使用{{}}这具有讽刺意味,因为人们认为选择它们是为了避免这种冲突。

简单地逃避花括号可以解决问题。

   columnDefs: [{
                    name: 'Column', width: 300, visible: true, cellTemplate: '<a href="modelremote:\{\{ grid.getCellValue(row, col) \}\}">\{\{ grid.getCellValue(row, col) \}\}</a>'
                }]
相关问题