1

I'm developing angular 8 app with Kendo UI.

So, I have this dropdown with custom template:

<kendo-dropdownlist name="theme"
                    [data]="themeItems"
                    [textField]="'text'"
                    [valueField]="'id'"
                    [(ngModel)]="theme"
                    (valueChange)="onChangeTheme($event)"
                    style="width: 100%">
    <ng-template kendoDropDownListValueTemplate let-dataItem>
        <span *ngIf="dataItem != null">
            <i class="fa fa-circle text-{{dataItem?.id}} pr-1"></i>{{ dataItem?.text }}
        </span>
    </ng-template>
    <ng-template kendoDropDownListItemTemplate let-dataItem>
        <span data-toggle="theme" [data-theme]="dataItem.url">
            <i class="fa fa-circle text-{{dataItem.id}} pr-1"></i>{{ dataItem.text }}
        </span>
    </ng-template>
</kendo-dropdownlist>

And themeItems:

themeItems = [
        {
            id: 'default',
            text: 'Default',
            url: 'default'
        }, {
            id: 'amethyst',
            text: 'Amethyst',
            url: 'assets/css/themes/amethyst.min.css'
        }, {
            id: 'city',
            text: 'City',
            url: 'assets/css/themes/city.min.css'
        }
];

And I see error Can't bind to 'data-theme' since it isn't a known property of 'span'

How can I resolve it?

A. Gladkiy
  • 3,134
  • 5
  • 38
  • 82

2 Answers2

0

I think it should be data-theme="{{dataItem.url}}"

no [] on the left but {{}} on the right side of the =

brandt.codes
  • 923
  • 2
  • 9
  • 19
0

Code should be: [attr.data-theme]="dataItem.url"

A. Gladkiy
  • 3,134
  • 5
  • 38
  • 82