0
エラーは発生していませんが、データは親コンポーネントに渡されていません。私がやっているやり方は、私がオンラインで探しているすべての例とはちょっと違うので、私はすでにそれをどのように設定しているかについてはあまり確信していません。ここまではコードです。@Outputを通してデータオブジェクトを渡す
私はParent Component
テンプレート
<multiple-choice-radio *ngIf="expbTrigger"
[question]="question01"
(selectedO)="selectedI" //where I'm trying to pull the data into parent component
></multiple-choice-radio>
でそれを呼んでいるにはどうすればChild Component
テンプレート
<input type="radio"
[attr.name] = "quesForm.value.name"
[attr.id] = "ans.id"
[attr.value] = "ans.answer"
(click) = "getSelected(ans)" //fetches data I want to pass
(click) = "sendAnswer()" //sets fetched data to @Output
hidden
/>
にChild Component
//a variable that stores the fetched data from a group of radio buttons
selected = {value1: '', value2: ''};
//the output variable
@Output() selectedO: EventEmitter<any> = new EventEmitter();
public sendAnswer =(): void => {
this.selectedO.emit(this.selected);
}
入力でそれを呼んでいる方法どのように私はそれを呼び出してParent Component
public selectedI(selected) {
this.selectedII = selected;
}
selectedII: any; //the variable I'm trying to store it into
これは私がこれをすべて動作させるようにするために合理化できる最良の方法です。私はここで間違って何をしていますか?
私は親コンポーネントのテンプレートのテンプレートにそれを追加すると仮定していますか?私はちょうどまだ値をロードしていないことをしました。 – Optiq
'(selectedO)=" selectedI "の代わりに –
私は自分の答えを更新しました。 'selectedI'はメソッドであり、プロパティではありません。 –