错误:初始化后无法更改选择的“多重"模式 [英] Error: Cannot change `multiple` mode of select after initialization

查看:54
本文介绍了错误:初始化后无法更改选择的“多重"模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误图片:

 <div fxFlex.gt-lg="100" fxFlex="100" *ngIf="requestAction == 'add'">
                    <div class="pb-1">
                            <md2-select placeholder="{{'WidgetType'|translate:lang}}" class="input_custom_width"(change)="widgetNode($event.value)"  required>
                                <md2-option *ngFor="let widgetType of widgetTypeAry" [value]="widgetType.value">
                                    {{widgetType.name}}
                                </md2-option>
                            </md2-select>
                    </div>
                </div>
              <div fxFlex.gt-lg="100" fxFlex="100" *ngIf="fieldsObj['node'] && showRequestAction" >
                <div class="pb-1">
                    <md2-select placeholder="{{'Node'|translate:lang}}" [formControl]="editWidgetForm.controls['nodeId']" [(ngModel)]="nodeId" class="input_custom_width" [(multiple)]="isMultiNode" (change)="nodeChange($event.value)" required>
                        <md2-select-header>
                            <md-input-container class="input_custom_width">
                                <input mdInput type="text" placeholder="{{'Search'| translate:lang}}" [ngModelOptions]="{standalone: true}" [(ngModel)]="searchNode"/>
                            </md-input-container>
                        </md2-select-header>
                        <md2-option *ngFor="let node of nodesAry | filterPipe : searchNode" [value]="node.value">
                            {{ node.name }}
                        </md2-option>
                    </md2-select>
                    <small *ngIf="editWidgetForm.controls['nodeId'].hasError('required') && editWidgetForm.controls['nodeId'].touched" class="mat-text-warn">{{'nodeReq'|translate:lang}}</small>
                </div>
              </div>

当我在选择下拉列表中使用倍数时,它可以正常工作,但是当我使用[倍数]时,它只能以我的编辑形式工作,而不能以加法形式工作.它给出了以上错误-错误:无法更改倍数初始化后的选择模式.请帮助我进行梳理.

When I use multiple in select dropdown it works fine but when I use [multiple] it only works in my edit form but not in add form .and it gives above error-Error: Cannot change multiple mode of select after initialization.help me to sort out this.

推荐答案

此问题有一个非常丑陋的解决方法,将您的mat-select变形为* ngif = true,然后使用被包装为Multiple的属性创建重复项* ngif =!true就在其下

There is a very ugly workaround for this problem, warp your mat-select in a *ngif=true, and create a duplicate with the multiple property, wrapped in a *ngif=!true just beneath it

这篇关于错误:初始化后无法更改选择的“多重"模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆