Skip to content

View.template cannot use the variable item #337

@hjzf

Description

@hjzf

Describe the bug
new Function cannot access the local variable item:

ReferenceError: item is not defined
    at eval (eval at m.template.y.format...

Possible reason
erupt-web/src/app/build/erupt/service/ui-build.service.ts:
571 - 581

if (view.template) {
    obj.format = (item: any) => {
        try {
            let value = item[view.column];
            return new Function('value', "return " + view.template)(value);
        } catch (e) {
            console.error(e);
            this.msg.error(e.toString());
        }
    };
}

A possible fix:

return new Function('value', 'item', "return " + view.template)(value, item);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions