如何使用angular2设置索引0的Validator not accept selected选项

如何使用angular2设置索引0的Validator not accept selected选项,angular,typescript,Angular,Typescript,我使用这样的选择选项 <div class="form-group row" [ngClass]="{'has-error': (!form.controls['blockFirstIndex'].valid && form.controls['blockFirstIndex'].touched), 'has-success': (form.controls['blockFirstIndex'].valid && form.controls['blockFi

我使用这样的选择选项

<div class="form-group row" [ngClass]="{'has-error': (!form.controls['blockFirstIndex'].valid && form.controls['blockFirstIndex'].touched), 'has-success': (form.controls['blockFirstIndex'].valid && form.controls['blockFirstIndex'].touched)}">
      <label class="col-sm-3 control-label">blockFirstIndex</label>
      <div class="col-sm-9">
            <select formControlName="blockFirstIndex" [(ngModel)]="value" class="form-control">
                 <option *ngFor="let item of items" [disabled]="item.id==0" [ngValue]="item">{{item.name}}</option>
            </select>
      </div>
</div>

如何使验证器不接受索引0的选择选项?

已禁用
应不允许选择值。。那么为什么要配置验证器呢?对,但在模板弹出窗口中选择第一个选项。所以我想配置验证器,不允许第一个选项。如果选项为--not set--@PankajParkar,则第一个选项是对其他用户的唯一提示
Form controller could be like this:

blockFirstIndex: new FormControl("", [
                    SelectionValidator.isValidSelection,
                    Validators.required
                ])

and you can define vlaidator like this:

import {FormControl} from '@angular/forms'; 
    export class SelectionValidator {
       static  isValidSelection(control: FormControl){
            if (control.value === "" || control.value=== "0") {
                return { "Please provide a valid selection": true };
            }
            return null;
        }

    }
Form controller could be like this:

blockFirstIndex: new FormControl("", [
                    SelectionValidator.isValidSelection,
                    Validators.required
                ])

and you can define vlaidator like this:

import {FormControl} from '@angular/forms'; 
    export class SelectionValidator {
       static  isValidSelection(control: FormControl){
            if (control.value === "" || control.value=== "0") {
                return { "Please provide a valid selection": true };
            }
            return null;
        }

    }