作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我一直在尝试使用 Angular UI-Grid 插件来呈现数据表,并且我有以下示例数据:
var data = [
{"id" : 10, "name" : "Name 1", "city" : "San Francisco"},
{"id" : 12, "name" : "Name 2", "city" : "San Diego"},
{"id" : 20, "name" : "Name 3", "city" : "Santa Barbara"},
];
下面是 gridOptions 的 columnDefs,在名称字段中,我需要使用 ui-sref 创建一个超链接
$scope.gridOptions.columnDefs = [
{field: 'id', displayName: 'ID'},
{field: 'name',
cellTemplate: '<div class="ui-grid-cell-contents tooltip-uigrid" title="{{COL_FIELD}}">' +
'<a ui-sref="main.placeDetail{{placeId: \'{{row.entity.id}}\' }}">{{COL_FIELD CUSTOM_FILTERS}}</a></div>'
},
{field: 'city', enableSorting: true}
];
除 row.entity.id 值外,表格呈现良好。我在超链接(名称列内)中获得的值是连续的:1、2 和 3,而不是 数据数组 中定义的 10、12 和 20 >,但是,ID 列中显示的 id 值正是我所期望的:10、12 和 20。我想知道您将如何访问 id name字段中的字段值,为什么name单元格中的id是连续的?
最佳答案
您不需要在 ui-sref
中使用大括号,因为您已经在 JS 表达式中。试试这个:
ui-sref="main.placeDetail({placeId: row.entity.id })"
关于javascript - Angular UI-Grid : In a cell template, 如何从不同的字段/单元格访问值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30939978/
我是一名优秀的程序员,十分优秀!