angular2 template - Generate angular 2 form after http callback -


i want generate angular 2 form group after receive response service. used following approach not work.i tried making service call , after receive response i'm trying generate form group not know how correct syntactically.

below app.component.ts

import { component,input }       '@angular/core';  import { formgroup,formbuilder  }                 '@angular/forms';      import { dropdownquestion } './question-dropdown';  import { questionbase }     './question-base';  import { textboxquestion }  './question-textbox';  import { dynamicformcomponent } './dynamic-form.component';    import { questionservice } './question.service';  import { questioncontrolservice }    './question-control.service';        @component({    selector: 'my-app',    template: `      <form [formgroup]="form">      <div *ngfor="let question of questions">        <input formcontrolname="question.key" id="question.key" type="question.type">      </div>      </form>    `,    providers:  [questionservice,dynamicformcomponent,questioncontrolservice]  })  export class appcomponent {    questions: any[];    form: formgroup;    constructor(service: questionservice, private dfc: dynamicformcomponent, private formbuilder: formbuilder) {        service.getbrowserdetails()      .then(()=>{        this.dataexistsfunction();      });            }      dataexistsfunction(){          this.form = this.formbuilder.group({});      this.questions = [{        key: 'firstname',        label: 'first name',        value: 'husain'      },{        key: 'lastname',        label: 'last name',        value: 'vohra'      }]    }  }


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -