При изменении значения в раскрывающемся списке проверяется, выпадает ли оно или нет. Если его выпадающий, то пользователь должен ввести значение выпадающего. При изменении выпадающего меню я вызываю функцию «ChangeSortOrder», но вместе с ней отправляется форма. Поэтому вместо NgSubmit я использовал кнопку «Отправить». Но теперь проблема в том, что он не проверяет обязательные поля и отправляет их, даже если значения пусты.
<form role="form" class="form form-horizontal" #Editform="ngForm" ngNativeValidate>
<div ngbDropdown class="col-md-6" style="float:left">
<button class="btn btn-outline-allow" id="dropdownBasic1" ngbDropdownToggle>{{selectedQuestionType}}</button>
<div ngbDropdownMenu aria-labelledby="dropdownBasic1">
<button class="dropdown-item" (click)="ChangeSortOrder('Text')">Text</button>
<button class="dropdown-item" (click)="ChangeSortOrder('DropDown')">DropDown</button>
</div>
<ul class="list-group ">
<li class="list-group-item" *ngIf="selectedQuestionType == 'DropDown'">
You have selected a Drop Down question. This means diner will select from 5 options in response to this question. This score can contribute to your overall score and section.
</li>
<li class="list-group-item" *ngIf="selectedQuestionType == 'Text'">
You have selected a text question. This means the diner will enter a text in response to this question. This score can contribute to your overall score and section.
</li>
</ul>
<!-- Question -->
<div class="form-group mt-2">
<div class="position-relative has-icon-left">
<textarea class="form-control" name="question" value={{editQuestion.question}} [(ngModel)]="question" required> </textarea>
<div class="form-control-position">
<i class="fa fa-question allow"></i>
</div>
</div>
</div>
<!-- DropDown -->
<div class="position-relative has-icon-left" *ngIf="selectedQuestionType == 'DropDown'">
<input type="text" class="form-control" name="DropDown1" [(ngModel)]="DropDown1" placeholder="Give Label for drop down" required/>
<div class="form-control-position">
<i class="fa fa-angle-double-right success"></i>
</div>
</div>
<div class="position-relative has-icon-left" *ngIf="selectedQuestionType == 'DropDown'">
<input type="text" class="form-control" name="DropDown2" [(ngModel)]="DropDown2" placeholder="Give Label for drop down" required/>
<div class="form-control-position">
<i class="fa fa-angle-double-right" style="color:#7CB342"></i>
</div>
</div>
</div>
<div class="pull-right col-md-6">
<div class="btn-group btn-group-toggle" ngbRadioGroup name="radioBasic" [(ngModel)]="modelRadio">
<label ngbButtonLabel class="btn-raised btn-outline-allow">
<input ngbButton type="radio" [value]="2"> Staff
</label>
<label ngbButtonLabel class="btn-raised btn-outline-allow">
<input ngbButton type="radio" [value]="3"> Marketing
</label>
</div>
<ul class="list-group">
<li class="list-group-item" *ngIf="modelRadio == 2">
You have selected a Staff question. We will provide you with insights on where are you performing well and where there is
room for improvement.
</li>
<li class="list-group-item" *ngIf="modelRadio == 3">
You have selected a Marketing question. We will provide you with insights on where are you performing well and where there is room for improvement.
</li>
</ul>
</div>
<button type="submit" (click)="onSubmit()" class="btn btn-raised btn-danger pull-right mt-2">Save</button>
</form>