Angular 2自定义验证器

时间:2016-10-31 13:54:24

标签: angular typescript

我升级了我的项目,我的验证器不再工作了。

我的验证员:

import {AnoMesCcValidator} from '../../validators/index';

this.formCartaoDeCredito = new FormGroup({
        anoMesCartaoDeCreditoControl: new FormControl('anoMesCartaoDeCreditoControl', [Validators.required])
    });

我的打字稿

<form [formGroup]="formCartaoDeCredito" role="form">
<div class="row">
<div class="col-xs-7 col-md-7">
    <div class="form-group">
        <label for="cardExpiry"><span class="hidden-xs">Vencimento</span><span class="visible-xs-inline">EXP</span></label>
        <input class="form-control"
               placeholder="MM / YYYY"
               autocomplete="cc-exp"
               onkeyup="formataMesAno(event)"
               maxlength="7"
               ano-mes-cc-validator
               formControlName="anoMesCartaoDeCreditoControl"
               [(ngModel)]="cartaoCredito.Validade" />
    </div>
</div>

我的模板:

p => p.Age

所以,不起作用,错误是“无法读取属性&#39;有效&#39;未定义&#39;,我已经设置#anoMesCartaoDeCreditoControl

0 个答案:

没有答案