esvit / ng-table

Simple table with sorting and filtering on AngularJS
http://esvit.github.io/ng-table
BSD 3-Clause "New" or "Revised" License
2.77k stars 851 forks source link

Won't work with custom interpolation #758

Open tnajdek opened 8 years ago

tnajdek commented 8 years ago

Because templates are already cached with {{ }}, setting up custom interpolation in my app will produce incorrect output (e.g. a placholder saying {{getFilterPlaceholderValue...)

The following should fix it (based on similar issue):

angular.module("ngTable").service(
    "$InterpolateUpdateService", function($templateCache, $interpolate){
        'use strict';

        this.changeGridInterpolate = function() {
            var templates = [
                'ng-table/filterRow.html',
                'ng-table/filters/number.html',
                'ng-table/filters/select-multiple.html',
                'ng-table/filters/select.html',
                'ng-table/filters/text.html',
                'ng-table/groupRow.html',
                'ng-table/header.html',
                'ng-table/pager.html',
                'ng-table/sorterRow.html'
            ];

            var start = $interpolate.startSymbol();
            var end = $interpolate.endSymbol();

            for (var i = 0; i < templates.length; i++) {
                var template = templates[i];
                var curTemplate = $templateCache.get(template);
                if (start !== "}}"){
                    curTemplate = curTemplate.replace(/\{\{/g, start);
                }
                if (end !== "}}"){
                    curTemplate = curTemplate.replace(/\}\}/g, end);
                }
                $templateCache.put(template, curTemplate);
            }
        };
    });

angular.module('ngTable').run(function($InterpolateUpdateService) {
    'use strict';

    $InterpolateUpdateService.changeGridInterpolate();
});
portokallidis commented 8 years ago

Does this mean that now we can render html inside cells?

gcsideal commented 8 years ago

Do you mean if (start !== "{{"){ ?

zwiy commented 7 years ago

Are there any news for this bug/improvement?

tuckbick commented 6 years ago

This is the issue I think: https://github.com/esvit/ng-table/issues/1021