【问题标题】:ng-grid does not work with file-referenced cell templateng-grid 不适用于文件引用的单元格模板
【发布时间】:2014-06-17 13:27:13
【问题描述】:

我正在使用angular-js + ng-grid,对于某些列,我想使用单元格模板。但是由于某种原因,当 template-html 作为文件存储和引用时,它不想工作。

    columnDefs: [ { 
       field: "Foo", 
       displayName: "Foo", 
       cellTemplate: '<div class="ngCellText"><input type="text" ng-model="row.entity[col.field]"/> </div>' 
    }] // OK

    columnDefs: [ { field: "Foo", displayName: "Foo", cellTemplate: 'cellTemplate.html' } ]
    // Error: [$parse:syntax] Syntax Error

此外,如果我从他们的网站点击指向plunkr 的链接,我会发现它不起作用。 (您可以点击链接查看确切的错误文本)。

【问题讨论】:

标签: javascript angularjs ng-grid


【解决方案1】:

如果您为外部模板指定另一个名称,而不是 $templateCache 中已有的名称,似乎可以工作。

    $scope.gridOptions = {
    data: 'myData',
    columnDefs: [{
        field: 'name',
        displayName: 'Name'
    }, {
        field: 'age',
        displayName: 'Age',
        cellTemplate: "exCellTemplate.html"
    }]
    };

工作Plunker

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-24
    • 2016-09-16
    • 1970-01-01
    相关资源
    最近更新 更多