本文整理汇总了TypeScript中@angular/common.FormBuilder.group方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FormBuilder.group方法的具体用法?TypeScript FormBuilder.group怎么用?TypeScript FormBuilder.group使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/common.FormBuilder
的用法示例。
在下文中一共展示了FormBuilder.group方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(private productService: ProductService) {
this.categories = this.productService.getAllCategories();
const fb = new FormBuilder();
this.formModel = fb.group({
'title': [null, Validators.minLength(3)],
'price': [null, positiveNumberValidator],
'category': ['']
})
}
示例2: constructor
constructor(private navController: NavController , private fb: FormBuilder) {
this.navController=navController;
this.authForm = fb.group({
'username': ['', Validators.compose([Validators.required, Validators.minLength(4), CustomValidators.checkFirstCharacterValidator])],
'password': ['', Validators.compose([Validators.required, Validators.minLength(4), CustomValidators.checkFirstCharacterValidator])]
});
this.username = this.authForm.controls['username'];
this.password = this.authForm.controls['password'];
}
示例3: toControlGroup
toControlGroup(questions: QuestionBase<any>[]) {
let group = {};
questions.forEach(q => {
group[q.key] = q.required ?
[q.value || '', Validators.required] :
[q.value || ''];
});
console.log(group);
// 构建表单验证选项
return this.fb.group(group);
}
示例4: constructor
constructor(params: RouteParams) {
var partyId = params.get('partyId');
this.party = Parties.findOne(partyId);
let fb = new FormBuilder();
this.partyForm = fb.group({
name: [''],
description: [''],
location: ['']
});
}
示例5: toControlGroup
toControlGroup(questions:QuestionBase<any>[] ) {
let group = {};
console.log(questions.length);
questions.forEach(question => {
group[question.key] = question.required ? [question.value || '', Validators.required] : [];
});
return this.fb.group(group);
}
示例6: constructor
constructor(public fb:FormBuilder, private _userService :UserService, public router:Router, private route: ActivatedRoute) {
this.route.params.subscribe(params => {
this.resetPasswordToken = params['token'];
});
this.resetPassForm = fb.group({
password: [""],
copass: [""],
})
}
示例7: constructor
constructor(
private userService: UserService,
private router: Router,
fb: FormBuilder
) {
this.loginForm = fb.group({
username: ["", Validators.required],
password: ["", Validators.required]
});
}
示例8: constructor
constructor(private router: Router) {
super();
let fb = new FormBuilder();
this.forgetForm = fb.group({
email: ['']
});
this.error = '';
}
示例9: constructor
constructor(
private loginService: LoginService,
private router: Router,
private fb: FormBuilder,
private appState: AppState,
private ws: WelcomeStateService) {
this.myForm = fb.group({
'email': [],
'password': []
});
}
示例10: ngOnInit
ngOnInit() {
this.myForm = this._fb.group({
firstName: ['', Validators.required],
lastName: ['', Validators.required],
email: ['', Validators.compose([
this.isEmail,
Validators.required
])], //compose allows you to pass multiple validators in an array
password: ['', Validators.required]
})
}