Version: "angular2": "2.0.0-beta.6"
I would like to implement a two way binding inside a parent/child component case.
On my child component, I'm using two-way binding to display text while editing.
Child component (InputTestComponent [selector:'input-test']
):
<form (ngSubmit)="onSubmit()" #testform="ngForm">
{{name}}
<textarea #textarea [(ngModel)]="name" ngControl="name" name="name"></textarea>
<button type="submit">Go</button>
</form>
Then, I would like to propagate this change to his parent component.
I tried with [(name)]="name"
with no success.
Parent component:
<div>
{{name}}
<input-test [(name)]="name"></input-test>
</div>
Code sample
What the easiest way to do it (less verbose) ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…