如果我想创建一个验证我的电子邮件的指令,该怎么做?
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
$builder->add('category', EntityType::class, array(
'class' => 'AppBundle:Category',
'choice_label' => function ($category) {
return $category->getDisplayName();
}
));
创建了该指令,但不知道如何实现验证规则/消息。
答案 0 :(得分:4)
首先,您不需要编写自己的验证器。
由于Angular v4.0.0-beta6是内置的电子邮件验证程序。
要使用它,请执行以下操作:
<input
type="email"
email
name="emailField"
[(ngModel)]="email"
#emailField="ngModel">
答案 1 :(得分:2)
你也可以通过constructor(public nav: NavController, private platform: Platform, public menu: MenuController) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need
platform.registerBackButtonAction(() => {
if(this.menu.isOpen()){
this.menu.close()
}
else if(this.nav.canGoBack()){
this.nav.pop();
}else{
//don't do anything
}
});
});
}
来实现它。像:
pattern