如何获得角度ui网格footerTemplate工作?

Cox*_*Szg 7 javascript footer angularjs angular-ui-grid

Angular UI-Grid有一个名为footerTemplate的属性,它可以提供创建自定义页脚模板的可能性.我尝试在字符串中输入html内容(带有一些文本的div),我也尝试在字符串中添加.html文件名,甚至是渲染div的ID,但它们似乎都不起作用.我也不清楚是否需要为此启用showGridFooter,所以我尝试了两者,但是footerTemplate根本没有显示,或者如果我将showGridFooter设置为true,它会显示默认的页脚(总行数)在网格中).我在这里错过了什么?

小智 9

对于angular-ui-grid 3.0.x,它使用以下示例选项:

$scope.options = {
                   showGridFooter: true,
                   gridFooterTemplate: '<div>pink floyd</div>'
};
Run Code Online (Sandbox Code Playgroud)

对于2.x ng-grid版本,Mokgra的版本很好.


小智 7

尝试在div标签中包含页脚模板

 $scope.gridOptions = {
            showGridFooter: true,
            gridFooterTemplate: "<div>Message Here</div>"
    }
Run Code Online (Sandbox Code Playgroud)

如果要显示任何范围变量

$scope.SomeScopeVariable = "Message Here";

$scope.gridOptions = {
        showGridFooter: true,
        gridFooterTemplate: "<div>Grid Footer: {{grid.appScope.SomeScopeVariable}}</div>"
}
Run Code Online (Sandbox Code Playgroud)

grid.appScope允许访问模板中的范围变量.用angular-ui-grid 3.0.x测试