Reputation: 95
I was wondering : how to bind the value of a component used by its selector in the template and an object declared in the model ?
The FormComponent has for selector "interface-form".
Here is the code :
@Component({
moduleId: 'module.id',
selector: 'create-interface',
template: '
<div class="content" style="margin : 20px;">
<div class="header-section row">
<button class="btn"> < Retour</button>
</div>
<interface-form [data]="data" [dataFields]="this.form.dataFields">
</interface-form>
</div>'
})
export class CreateComponent {
public form: FormComponent;
...
I would like my form attribute to be the instance of interface-form declared in my template, so if i do this :
this.form.addField(...), my template will dynamically change.
Upvotes: 0
Views: 295
Reputation: 7490
I think what you are looking for is FormArray
. Check it out:
https://angular.io/docs/ts/latest/api/forms/index/FormArray-class.html
Upvotes: 1