1

I am trying to display data in drop down select list using angular formly. The drop down list appear to be blank. Here is the code snippet. Can some please help??

component.ts

 this.fields = [
  {
        key: 'Branch',
        type: 'select',
        defaultValue: 'develop',
        templateOptions: {
          required: true,
          label: 'Branches',
          description: 'Select the Branch to deploy in test',
          options: this.artifactory.getArtifacts('star')
        }
]

service.ts

 getArtifacts(artifact: string) {
    let data: Observable<string[]> = of([]);

    let artifactType = new HttpParams().set('artifact', artifact)
    data = this.httpClient.get<string[]>(`${environment.api}branches`, { params: artifactType }).pipe();
    return data;
  }

html

 <form [formGroup]="form">
    <formly-form [form]="form" [fields]="fields"></formly-form>
  </form>
</div>

enter image description here

1 Answer 1

3

You'll have to define valueProp and labelProp values in templateOptions as per your api response

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.