get data from json

This commit is contained in:
annampak 2017-11-27 18:42:26 +02:00
parent 722cd8b482
commit d5d3f5ef37
6 changed files with 21 additions and 11 deletions

View File

@ -17,7 +17,7 @@ export class CompositeFieldFormComponent {
constructon(){} constructon(){}
ngOnInit(){ ngOnInit(){
this.addNewField(); // this.addNewField();
} }
addNewField(){ addNewField(){

View File

@ -17,7 +17,7 @@ export class FieldFormComponent {
constructon(){} constructon(){}
ngOnInit(){ ngOnInit(){
this.addNewRule(); //this.addNewRule();
} }
addNewRule(){ addNewRule(){

View File

@ -17,7 +17,7 @@ export class GroupFieldFormComponent {
constructor(){} constructor(){}
ngOnInit(){ ngOnInit(){
this.addNewField(); // this.addNewField();
} }
addNewField(){ addNewField(){

View File

@ -1,4 +1,4 @@
<div> <div><!--style="border-style: solid;"-->
<h4 style="text-decoration: underline;">Section</h4> <h4 style="text-decoration: underline;">Section</h4>
<div [formGroup]="form"> <div [formGroup]="form">
<div class="form-row"> <div class="form-row">
@ -8,17 +8,25 @@
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label>Id</label> <label>Id</label>
<input type="text" class="form-control" formControlName="id"> <input type="text" class="form-control" formControlName="id">
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label>defaultVisibility</label> <label>defaultVisibility</label>
<input type="text" class="form-control" formControlName="defaultVisibility"> <input type="text" class="form-control" formControlName="defaultVisibility">
</div> </div>
</div> </div>
</div> </div>
<div *ngFor="let fieldGroup of dataModel.fieldGroups let i=index;"> <div *ngIf="dataModel.sections">
<groupfield-form [form]="form.get('fieldGroups').get(''+i)" [dataModel]="fieldGroup" ></groupfield-form> <div *ngFor="let section of dataModel.sections let i=index;">
<section-form [form]="form.get('sections').get(''+i)" [dataModel]="section"></section-form>
</div>
</div> </div>
<div *ngIf="dataModel.fieldGroups">
<div *ngFor="let fieldGroup of dataModel.fieldGroups let i=index;">
<groupfield-form [form]="form.get('fieldGroups').get(''+i)" [dataModel]="fieldGroup"></groupfield-form>
</div>
</div>
<div> <div>
<a (click)="addGroupField()" style="cursor: pointer"> <a (click)="addGroupField()" style="cursor: pointer">
Add another group + Add another group +

View File

@ -18,12 +18,13 @@ export class SectionFormComponent {
constructor(){ } constructor(){ }
ngOnInit(){ ngOnInit(){
this.addGroupField(); //this.addGroupField(); //for new DatasetProfile
} }
addGroupField(){ addGroupField(){
let fieldGroup:FieldGroup = new FieldGroup(); let fieldGroup:FieldGroup = new FieldGroup();
this.dataModel.fieldGroups.push(fieldGroup); if(this.dataModel.fieldGroups)
this.dataModel.fieldGroups.push(fieldGroup);
(<FormArray>this.form.get("fieldGroups")).push(fieldGroup.buildForm()); (<FormArray>this.form.get("fieldGroups")).push(fieldGroup.buildForm());
} }

View File

@ -26,7 +26,8 @@ export const TestModel = {
"title": "", "title": "",
"description": "", "description": "",
"extendedDescription": "", "extendedDescription": "",
"viewStyle": "checkBox" "viewStyle": "checkBox",
"rule":[]
} }
] ]
} }