本文整理汇总了TypeScript中@angular/common.Control类的典型用法代码示例。如果您正苦于以下问题:TypeScript Control类的具体用法?TypeScript Control怎么用?TypeScript Control使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Control类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('resets a control', () => {
let control: Control = new Control('');
let returnedControl: AbstractControl = null;
control.markAsTouched();
control.updateValue('dave');
returnedControl = Utils.resetControl(control);
expect(returnedControl.touched).toBe(false);
expect(returnedControl.untouched).toBe(true);
expect(returnedControl.pristine).toBe(true);
expect(returnedControl.dirty).toBe(false);
expect(returnedControl.value).toBe('');
});
示例2: it
it('should check is value is a valid email', () => {
let control = new Control('test@test.nl');
let result: ValidationResult = FormValidators.isMailAddress(control);
expect(result).toBeDefined();
expect(result['mail_format_error']).toBe(false);
// set value to alphanumeric
control.updateValue('abc');
result = FormValidators.isMailAddress(control);
expect(result['mail_format_error']).toBe(true);
});
示例3: setTimeout
setTimeout(()=> {
this.formDir.form.addControl(this.field.name,this.fieldControl);
let value:any = '';
if(this.entity && this.entity.extraFields && this.entity.extraFields[this.field.name]) {
value = this.entity.extraFields[this.field.name];
} else if(this.field.hasValue()) {
value = this.field.value;
this.entity.extraFields[this.field.name] = value;
console.log(this.entity);
}
if(!this.field.isTypeFile()) {
this.fieldControl.updateValue(value);
}
}, 0);
示例4: showAllData
/**
* Sets the filters for year from and year to such that all data is shown.
*/
showAllData() {
if (!this.years)
return;
this.yearFrom.updateValue(this.years[0]);
this.yearTo.updateValue(this.years[this.years.length-1]);
}
示例5: send
/**
* Form submit handler.
* Send a Message to the Room with id.
*/
send() {
if (this.message.valid) {
// Send message to server
this._roomService.sendMessage(parseInt(this._routeParams.get('id')), this.messageForm.value.message);
// Reset the form
this.message.updateValue('');
}
}
示例6:
.catch(error => {
this.password.updateValue("");
if (error.code === "auth/invalid-email" || error.code === "auth/wrong-password") {
this.showLoginFailure("Email or password invalid");
return;
}
if (error.code === "auth/user-disabled") {
this.showLoginFailure("User has been disabled");
return;
}
if (error.code === "auth/user-not-found") {
this.showLoginFailure("User not found");
return;
}
});
示例7:
.catch(error => {
this.password.updateValue("");
if (error.code === "auth/email-already-in-use") {
this.showLoginFailure("Email already exists an account");
return;
}
if (error.code === "auth/invalid-email") {
this.showLoginFailure("Email address is not valid");
return;
}
if (error.code === "auth/operation-not-allowed") {
this.showLoginFailure("Email/password accounts are not enabled");
return;
}
if (error.code === "auth/weak-password") {
this.showLoginFailure("Password is not strong enough");
return;
}
});
示例8:
res => {
this.ctrlRegPasswordConfirm.updateValue("");
this.login();
this.turnOffError();
},