ionic2 导入时 CORE_DIRECTIVES,FORM_DIRECTIVES,等 时报错 Typescript Error
发布于 5天前 作者 yulong132 38 次浏览 来自 问答

查阅了一个共享的项目来学习: http://www.cnblogs.com/madyina/p/5970814.html

其中有个验证的类: import {CORE_DIRECTIVES,FORM_DIRECTIVES,FormBuilder,ControlGroup,Control,Validators,AbstractControl } from '@angular/common’

export function emailValidator(control: Control): { [s: string]: boolean } { if (!control.value.match(/^(\w)+(.\w+)*@(\w)+((.\w+)+)$/)) { return { invalidEmail: true }; } }

export function nicknameValidator(control: Control): { [s: string]: boolean } { if (!control.value.match(/^[(\u4e00-\u9fa5)0-9a-zA-Z_\s@]+$/)) { return { invalidNickname: true }; } } 报错了: 20161129160528.png 20161129160556.png

大家看看是怎么回事呢?

2 回复

//import {CORE_DIRECTIVES,FORM_DIRECTIVES,FormBuilder,ControlGroup,Control,Validators,AbstractControl } from '@angular/common’ import { FormBuilder, Validators, FormGroup, FormControl } from '@angular/forms’; 1

export function emailValidator(control: FormControl): { [s: string]: boolean } { if (!control.value.match(/^(\w)+(.\w+)*@(\w)+((.\w+)+)$/)) { return { invalidEmail: true }; } }

export function nicknameValidator(control: FormControl): { [s: string]: boolean } { if (!control.value.match(/^[(\u4e00-\u9fa5)0-9a-zA-Z_\s@]+$/)) { return { invalidNickname: true }; } }

回到顶部