コンポーネントがあります。それはUserComponent
としましょう。このコンポーネントには、データを表示するためのグリッドコンポーネントが含まれます。各行のセルには、削除、編集、グラフなどのボタンがあります。あなたはselecedUser
はapp-edit-user-graph
に、別のコンポーネントに渡され、見ることができるよう、 this.selectedUser = this.tableApi.row($tr).data();
そして: 角度2.入力データが変更された後、角レンダリングのレンダリングを理解するにはどうすればよいですか?
<div>
...grid component goes here
... and other stuff
<app-edit-user-graph [user]="selectedUser" [department]="department" [organization]="organization"></app-edit-user-graph>
</div>
ユーザーがセル内部のGraph
ボタンをクリック
このコンポーネントはモーダルウィンドウであり、多くの選択コンポーネントと他のコントロールがあります。
<th *ngFor="let name of heads">
<div>
<span>{{name}}</span>
<span>
<ng-select [items]="userProjects"
[allowClear]="true"
(data)="update($event, name)"
[active]="setActive(name)">
</ng-select>
</span>
</div>
</th>
は私がapp-edit-user-graph
コンポーネントの変化を聞く:
@ViewChildren(SelectComponent)
selects: SelectComponent[];
@Input() user: User;
... other inputs
ngOnChanges(changes) {
if (!changes.user || (changes.user && !changes.user.currentValue.id)) {
return;
}
this.userService.getUserProjects(this.user.id).subscribe(p=> {
this.userProjects = p;
this.updateSelects();
}
}
public updateSelects() {
let rowSelects = this.selects;
let selectedValues = this.getSelectedValue(rowSelects);
let availableValues = this.getAvailableValues(selectedValues, this.userProjects);
rowSelects.forEach(s => {
s.items = availableValues;
})
}
すべての選択コンポーネントを取得し、いくつかの値をフィルタthis.updateSelects
方法これは、そのテンプレートの一部です。 問題は次のとおりです。最初にクリックすると、updateSelects
の方法でselects
メソッドが空です。私はAngularがレンダリングの選択を終えていなかったので、理由を理解しています。私がもう一度モーダルを開くと、他のレコードのために私は前のセレクトセットを取得します。
入力データが変更された後に角レンダリングがどのように理解されるのでしょうか。
をあなたは[Plunker](https://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5)の例を作ることはできますか? – adriancarriger
@adriancarrigerグリッドや他の第三者コンポーネントのために非常に難しいでしょう。 – user348173