本文整理汇总了TypeScript中@angular/forms.FormBuilder.array方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FormBuilder.array方法的具体用法?TypeScript FormBuilder.array怎么用?TypeScript FormBuilder.array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/forms.FormBuilder
的用法示例。
在下文中一共展示了FormBuilder.array方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should create control arrays', () => {
var c = b.control('three');
var a = b.array(
['one', ['two', syncValidator], c, b.array(['four'])], syncValidator, asyncValidator);
expect(a.value).toEqual(['one', 'two', 'three', ['four']]);
expect(a.validator).toBe(syncValidator);
expect(a.asyncValidator).toBe(asyncValidator);
});
示例2: it
it('should create control arrays', () => {
const c = b.control('three');
const e = b.control(null);
const f = b.control(undefined);
const a = b.array(
['one', ['two', syncValidator], c, b.array(['four']), e, f], syncValidator,
asyncValidator);
expect(a.value).toEqual(['one', 'two', 'three', ['four'], null, null]);
expect(a.validator).toBe(syncValidator);
expect(a.asyncValidator).toBe(asyncValidator);
});
示例3: ngOnInit
ngOnInit() {
this.myFormGroup = this.fb.group({
myElements: this.fb.array([])
});
this.addElementToArray();
}
示例4: createForm
createForm() {
this.privacyForm = this.fb.group({
policyHeading: [''],
policies: this.fb.array([]),
});
this.addForm();
}
示例5: ngOnInit
ngOnInit() {
this.registrationForm = this.fb.group({
userName: ['', [Validators.required, Validators.minLength(3), forbiddenNameValidator(/password/)] ],
password: [''],
email: [''],
subscribe: [''],
confirmPassword: [''],
address: this.fb.group({
city: [''],
state: [''],
postalCode: ['']
}),
alternateEmails: this.fb.array([])
}, {validator: PasswordValidator});
this.registrationForm.get('subscribe').valueChanges
.subscribe(checkedValue => {
const email = this.registrationForm.get('email');
if (checkedValue) {
email.setValidators(Validators.required);
} else {
email.clearValidators();
}
email.updateValueAndValidity();
});
}
示例6: createForm
createForm() {
this.faqForm = this.fb.group({
faqHeading: [''],
faqs: this.fb.array([]),
});
this.addForm();
}
示例7: setObjectives
setObjectives() {
/* const objectives = this.board.selectObjectives
.map(o => { return { organizationId: o.organization.id, objective: o.objective }}); */
const objectiveFGs = this.board.selectObjectives.map(o => this.fb.group(o));
const objectiveFormArray = this.fb.array(objectiveFGs);
this.form.setControl('selectObjectives', objectiveFormArray);
}
示例8: ngOnInit
ngOnInit() {
this.formArray =
this.builder.array([]);
this.formGroup = this.builder.group({
positionen: this.formArray
});
}
示例9: initClubTimeLine
// TimeLine
initClubTimeLine(): FormArray {
const formArray = [];
if (this.club.timeLine) {
for (let i = 0; i < this.club.timeLine.length; i++) {
formArray.push(this.initTimeLineEvent(this.club.timeLine[i]));
}
}
return this.fb.array(formArray);
}
示例10: constructor
// I initialize the reactive-form component.
constructor( formBuilder: FormBuilder ) {
this.formBuilder = formBuilder;
this.form = this.formBuilder.group({
pets: this.formBuilder.array( [] )
});
}
示例11: savePv
savePv(pv: PersistentVolume) {
if (pv && pv.spec) {
this.pv = pv;
let storage;
if (pv.spec.capacity) {
storage = parseFloat(pv.spec.capacity['storage']);
}
let readWriteOnce = false;
let readOnlyMany = false;
let readWriteMany = false;
if (pv.spec.accessModes && pv.spec.accessModes.length > 0) {
pv.spec.accessModes.map(key => {
switch (key) {
case 'ReadWriteOnce':
readWriteOnce = true;
break;
case 'ReadOnlyMany':
readOnlyMany = true;
break;
case 'ReadWriteMany':
readWriteMany = true;
break;
}
});
}
let labels = Array<FormGroup>();
if (pv.metadata.labels) {
Object.getOwnPropertyNames(pv.metadata.labels).map(key => {
labels.push(this.fb.group({
key: key,
value: pv.metadata.labels[key]
}))
});
}
let type = '0';
if (pv.spec.cephfs) {
type = 'cephfs';
} else if (pv.spec.rbd) {
type = 'rbd';
}
this.currentForm = this.fb.group({
name: pv.metadata.name,
type: type,
storage: storage,
rbdImage: pv.spec.rbd ? pv.spec.rbd.image : '',
cephfsPath: pv.spec.cephfs ? pv.spec.cephfs.path : '',
accessModes: this.fb.group({
ReadWriteOnce: readWriteOnce,
ReadOnlyMany: readOnlyMany,
ReadWriteMany: readWriteMany,
}),
labels: this.fb.array(labels)
});
}
}
示例12: createForm
createForm() {
this.form = this.fb.group({
'active': null,
'title': null,
'rankId': null,
'conveneOn': null,
'selectObjectives': this.fb.array([])
});
}
示例13: it
it('should set updateOn with nested arrays', () => {
const g = b.group(
{
arr: b.array([b.control(''), b.control('')]),
},
{updateOn: 'blur'});
expect(g.get(['arr', 0]) !.updateOn).toEqual('blur');
expect(g.get(['arr', 1]) !.updateOn).toEqual('blur');
expect(g.get('arr') !.updateOn).toEqual('blur');
});
示例14: constructor
constructor(builder: FormBuilder) {
this.registrationForm = builder.group({
username: null,
email: null,
password: null,
address: builder.group({
street: null,
city: null,
zip: null
}),
phones: builder.array([builder.control(null)])
});
}
示例15: ngOnInit
ngOnInit() {
this.myFormGroup = this.fb.group({
angles: this.fb.array([])
});
this.addAngle();
this.addAngle();
this.addAngle();
this.angleArray.valueChanges
.pipe(debounceTime(1500))
.subscribe(() => {
this.recalculateTheAngles();
});
}