本文整理汇总了TypeScript中@angular/common.FormBuilder.control方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FormBuilder.control方法的具体用法?TypeScript FormBuilder.control怎么用?TypeScript FormBuilder.control使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/common.FormBuilder
的用法示例。
在下文中一共展示了FormBuilder.control方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(builder: FormBuilder) {
this.form = builder.group({
username: builder.control('', Validators.required),
password: builder.control('', Validators.compose([
Validators.required,
Validators.minLength(10)
]))
});
}
示例2: constructor
constructor(private fb: FormBuilder, private userService: UserService, private router: Router) {
// Create the username form control
this.username = fb.control('', Validators.compose([Validators.required, Validators.minLength(3)]));
this.username.valueChanges.subscribe((newValue) => { this.usernameErrorMessage = ''; });
// Create the password form control
this.password = fb.control('', Validators.compose([Validators.required]));
this.password.valueChanges.subscribe((newValue) => { this.passwordErrorMessage = ''; });
// Create the group
this.userForm = fb.group({ username: this.username, password: this.password });
}
示例3: constructor
constructor(builder: FormBuilder) {
this.form = builder.group({
username: builder.control('', Validators.required),
password: builder.control('', Validators.compose([
Validators.required,
Validators.minLength(10),
function containsCapital(control: Control) {
const reg = /[A-Z]/;
if (reg.test(control.value)) {
return null;
} else {
return {
containsCapital: true
};
}
}
]))
});
}
示例4: constructor
constructor(builder: FormBuilder) {
this.form = builder.group({
username: builder.control('', Validators.required,
function usernameExists(control: Control) {
return new Promise((resolve) => {
setTimeout(() => {
if (control.value === 'Max') {
resolve({
usernameExists: true
});
} else {
resolve(null);
}
}, 1000);
});
}),
password: builder.control('',
Validators.compose([Validators.required, Validators.minLength(10)]))
});
}
示例5: _guestBuilder
private _guestBuilder(form: ControlGroup) {
form.addControl("name", this._fb.control(""));
}
示例6: createControl
createControl(): AbstractControl {
return this._control = this.formBuilder.control(this._model ? "on" : undefined);
}
示例7: createControl
createControl(): AbstractControl {
return this.formBuilder.control(this.model[this.key] ? "on" : undefined);
}
示例8: constructor
constructor(builder: FormBuilder) {
this.form = builder.group({
username: builder.control(''),
password: builder.control('')
});
}