ng-table icon indicating copy to clipboard operation
ng-table copied to clipboard

Won't work with custom interpolation

Open tnajdek opened this issue 10 years ago • 4 comments

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();
});

tnajdek avatar Nov 27 '15 02:11 tnajdek

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

portokallidis avatar Dec 11 '15 09:12 portokallidis

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

gcsideal avatar Dec 12 '15 14:12 gcsideal

Are there any news for this bug/improvement?

zwiy avatar May 22 '17 13:05 zwiy

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

tuckbick avatar Apr 07 '18 16:04 tuckbick