本文整理汇总了TypeScript中@angular/forms.FormGroup.patchValue方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FormGroup.patchValue方法的具体用法?TypeScript FormGroup.patchValue怎么用?TypeScript FormGroup.patchValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/forms.FormGroup
的用法示例。
在下文中一共展示了FormGroup.patchValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: toggleParagraph
/**
* Called by the template when a paragraph is clicked in multiple paragraph mode.
* Behaves like a checkbox
*
* @param {ParagraphToChoose} paragraph
*/
public toggleParagraph(paragraph: ParagraphToChoose): void {
let newParagraphs: ParagraphToChoose[];
const oldSelected: ParagraphToChoose[] = this.contentForm.value.selectedParagraphs;
if (this.isParagraphSelected(paragraph)) {
newParagraphs = oldSelected.filter(para => para.paragraphNo !== paragraph.paragraphNo);
this.contentForm.patchValue({
selectedParagraphs: newParagraphs
});
this.contentForm.removeControl('text_' + paragraph.paragraphNo);
} else {
newParagraphs = Object.assign([], oldSelected);
newParagraphs.push(paragraph);
newParagraphs.sort(
(para1: ParagraphToChoose, para2: ParagraphToChoose): number => {
if (para1.paragraphNo < para2.paragraphNo) {
return -1;
} else if (para1.paragraphNo > para2.paragraphNo) {
return 1;
} else {
return 0;
}
}
);
this.contentForm.addControl(
'text_' + paragraph.paragraphNo,
new FormControl(paragraph.rawHtml, Validators.required)
);
this.contentForm.patchValue({
selectedParagraphs: newParagraphs
});
}
}
示例2: ngOnInit
ngOnInit() {
this.settingsForm = this.fb.group({
id: 1,
server_url: ['', Validators.required ]
});
this.settingsForm.patchValue({ server_url: localStorage.getItem('server_url') });
}
示例3:
user => {
this.id = user.id;
this.userForm.patchValue({
username: user.username,
address: user.address,
email: user.email
});
}, error => {
示例4: onEditButton
/**
* Category specific edit button
* @param viewCategory individual cat
*/
public onEditButton(viewCategory: ViewCategory): void {
this.editId = viewCategory.id;
this.updateForm.reset();
this.updateForm.patchValue({
prefix: viewCategory.category.prefix,
name: viewCategory.name
});
}
示例5:
this.profileService.getProfile(user.username).subscribe((profile :Profile)=>{
this.profile_form.patchValue({
'name' : profile['name'],
'bio' : profile['bio'],
'company' : profile['company']
});
this.profile_image = profile.profile_image;
});
示例6: clearInputImage
clearInputImage(field: string, fieldContentType: string, idInput: string) {
this.editForm.patchValue({
[field]: null,
[fieldContentType]: null
});
if (this.elementRef && idInput && this.elementRef.nativeElement.querySelector('#' + idInput)) {
this.elementRef.nativeElement.querySelector('#' + idInput).value = null;
}
}
示例7: updateIngredients
private updateIngredients(newIngredient: Ingredient): void {
const ingredients = this.getCurrentIngredients();
const existingIndex = findIndex(ingredients, ((i) => i.id === newIngredient.id));
if (existingIndex > -1) {
ingredients[existingIndex] = newIngredient;
} else {
ingredients.push(newIngredient);
}
this.recipeForm.patchValue({ingredients});
}
示例8: ngOnChanges
ngOnChanges(changes: SimpleChanges) {
if(changes.candidate) {
this.form.patchValue({
'panelId': this.panelId,
'boardId': this.boardId,
'candidateId': this.candidate.id,
'recordId': this.candidate.recordId,
})
}
}
示例9: ngOnInit
ngOnInit() {
this.form = this.fb.group({
pay_account: [null, Validators.compose([Validators.required, Validators.email])],
receiver_type: [null, [Validators.required]],
receiver_account: [null, [Validators.required]],
receiver_name: [null, Validators.compose([Validators.required, Validators.minLength(2)])],
amount: [null, Validators.compose([Validators.required, Validators.pattern(`[0-9]+`), Validators.min(1), Validators.max(10000 * 100)])]
});
this.form.patchValue(this.item);
}
示例10: displayData
displayData(): void {
//this.postForm.setValue({
// title: '샘플 제목',
// content: '샘플 내용\n샘플 내용\n',
// blogId: 1
//});
this.postForm.patchValue({
title: '샘플 제목',
content: '샘플 내용\n샘플 내용\n'
});
}
示例11: autoFill
@DeveloperFunction({
args: [
{
username: 'NextFaze',
password: 'devmod-development'
}
]
})
autoFill(args: any) {
this.form.patchValue(args);
}
示例12: loadApiData
loadApiData(){
this.registrationForm.patchValue({
userName: "Jonathan",
password: "test",
confirmPassword: "test",
address: {
city: "Miami",
state: "FL",
postalCode: "33023"
}
});
}
示例13: setParagraph
/**
* Called by the template when a paragraph is clicked in single paragraph mode.
* Behaves like a radio-button
*
* @param {ParagraphToChoose} paragraph
*/
public setParagraph(paragraph: ParagraphToChoose): void {
this.contentForm.value.selectedParagraphs.forEach(para => {
this.contentForm.removeControl('text_' + para.paragraphNo);
});
this.contentForm.addControl(
'text_' + paragraph.paragraphNo,
new FormControl(paragraph.rawHtml, Validators.required)
);
this.contentForm.patchValue({
selectedParagraphs: [paragraph]
});
}
示例14: ngOnInit
ngOnInit() {
this.createForm();
this.store.select(fromStore.getBoard).subscribe(boardDetails => this.board = boardDetails);
this.form.patchValue({
active: this.board.active,
title: this.board.title,
rankId: this.board.rank.id,
conveneOn: this.board.conveneOn,
});
this.setObjectives();
}
示例15:
.subscribe((response) => {
this.errormsg = '';
this.coreservice.emitSuccessMessage(response.message);
//this.successmsg = response.data.message;
window.localStorage['teem_user'] = JSON.stringify(response.data);
this.accountFormGroup.patchValue({
email: response.data.email
});
this.router.navigate(['']);
},