2017-12-01から1日間の記事一覧
ngOnChangesを使って、子に渡したプロパティが変わったことを検知する 親コンポーネント /** app.component.ts */ export class AppComponent { public datas = 1; onClick() { this.datas ++; } } <button (click)="onClick()">押してください</button> <app-child [parentProperty]='datas'></app-child> 子コンポーネント
Angular2/4にて、Cannot find name SimpleChangesエラー 変更検知をしたかったので、以下の記述をしたところ、 Cannot find name 'SimpleChanges'. というコンパイルエラーが出た。 export class ChildComponent implements OnInit, OnChanges { @Input() pa…
結論 *ngIfを使うとComponent自体消えてしまうが、 [hidden]を使うと非表示になるだけでComponentはそのまま残る。 *ngIfの場合 <app-sample *ngIf="showFlg"></app-sample> [hidden]の場合 <app-sample [hidden]="showFlg"></app-sample> いきさつ Angular2/4にて、こんなことがあった 2つのComponentA、ComponentBがある タブAがアクティブの時Co…