Hi,

[url]http://ng2-dynamic-forms.udos86.de/sample/index.aot.html#/primeng-sample-form[/url]
  
Here I am using dynamic form.




[code]  dynamicSelectModelBirims: SelectModel[] = [];[/code]
[code] export class SelectModel {
    label: string;
    value: any;
}[/code]
[code] 
 constructor(private formService: DynamicFormService, private 
helperService: HelperService,
    private birimlerService: BirimlerService) {

    setTimeout(() => {
      this.dynamicFormCreate();
      this.formGroupValue = 
this.formService.createFormGroup(this.formModel);

    }, 100);
    // this.getBirims();
    setTimeout(() => {
      this.getBirims();

    }, 1000);

  }[/code]

[code]   FORM_MODEL.push(new DynamicSelectModel<string>({
          id: element.propertyName,
          label: element.displayName,
          placeholder: element.displayName,
          options: this.dynamicSelectModelBirims, // or this.getBirims();
          
          //value: "Aktif",
          //disabled: false,

        }))
[/code]


[code]
 getBirims() {
    this.birimlerService.get().subscribe(
      (data: any) => {
        if (data.statusCode == 200) {
          this.birimler = data;


          this.birimler.data.forEach(element => {
            this.dynamicSelectModelBirims.push({
              label: element.birimAdi,
              value: element.id
            });
          });
        }
      }
    );
[/code]


[code]

    <div class="overflow-hidden content-margin content-padding" 
style="width: 100%;">
        <!-- <pre>{{ dynamicform | json }}</pre> -->
        <form [formGroup]="formGroupValue" class="ui-fluid" 
style="align-content: center">

            <dynamic-primeng-form [group]="formGroupValue" 
[layout]="layoutJson" [model]="formModel"
                (change)="onChange($event)" 
(pEvent)="onPEvent($event)"></dynamic-primeng-form>

        </form>

        <!-- <button type="button" class="" icon="pi pi-check"  
label="Kaydet"></button> -->

    </div>
[/code]


[url=https://hizliresim.com/mMboJ0][img]https://i.hizliresim.com/mMboJ0.jpg[/img][/url]






*The dynamic form in which I have provided code examples above must be 
loaded with dropdown data before loading html page. But because of the html 
page was previously installed, the page is loading with an empty dropdown 
before the service set datas to object. So the dropdown is empty. But when 
I print with console.log, the dynamicSelectModelBirims object has data. How 
can I solve this asynchronous problem ?*

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to