1

我正在使用 PrimeNG,我无法添加一些按钮来清除输入。这是我的html:

<p-dropdown (keyup)='search($event)'  
                        id = "dropdown"
                        (onChange)="changeSubject($event.value)" 
                        [options]="subjects" 
                        [(ngModel)]="selectedSubject" 
                        filterBy = 'subjects'
                        [filter] = 'true'
                        [autoDisplayFirst] = 'defaultFilter'
                        #dropdown
                        placeholder="{{selectedWord}}"
                        [style]="{'width':'100%', 'height': '30px'}">
            </p-dropdown>
4

1 回答 1

1

您可以添加showClear适当性并将其设置为true

<p-dropdown (keyup)='search($event)'  
                    id = "dropdown"
                    (onChange)="changeSubject($event.value)" 
                    [options]="subjects" 
                    [(ngModel)]="selectedSubject" 
                    filterBy = 'subjects'
                    [filter] = 'true'
                    [autoDisplayFirst] = 'defaultFilter'
                    #dropdown
                    placeholder="{{selectedWord}}"
                    [style]="{'width':'100%', 'height': '30px'}"
                    showClear="true">
        </p-dropdown>
于 2018-11-06T22:44:15.837 回答