1

我正在使用 Kendo UI 开发 Angular 8 应用程序。

所以,我有这个带有自定义模板的下拉列表:

<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>

并且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'
        }
];

我看到错误Can't bind to 'data-theme' since it isn't a known property of 'span'

我该如何解决?

4

2 回答 2

0

代码应该是:[attr.data-theme]="dataItem.url"

于 2019-10-10T10:28:29.277 回答
0

我认为应该是 data-theme="{{dataItem.url}}"

没有[]在左边但{{}}在右边=

于 2019-10-10T09:46:15.987 回答