我有2個組件:RegistrationComponent和RegistryComponent。Angular 2親子溝通
RegistrationComponent:
@Component({
selector: 'registration_page',
template:
'<div>
<registry_form [model]="parentModel"></registry_form>
<label>{{parentModel}}</label>
</div>,
styleUrls: [...],
directives: [...],
providers: []
})
export class RegistrationComponent
{
parentModel : string;
constructor()
{
this.parentModel = "parent"
}
}
RegistryComponent:
@Component({
selector: 'registry_form',
template:
'
<label for="name">name {{model}}</label>
<input [(ngModel)]="model" required >
',
styleUrls: [...],
directives: [...]
})
export class RegistryFormComponent
{
@Input() model;
}
當我寫在輸入一些文字在RegistryComponent我可以看到的變化,但不是在RegistrationComponent巫父組件。我錯過了什麼?
https://toddmotto.com/component-events-event-emitter-output-angular-2 – Matt