本文整理匯總了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]
})
}