【发布时间】:2021-07-13 11:44:04
【问题描述】:
我在 chlid 组件中有一个按钮,它有一个表单,单击该按钮时,它会添加到 DB 中并发出警报。我想在显示数据库中数据列表的父组件屏幕中显示警报。
HTML:
<button class="pt-primary adconfig-button" *ngIf="!isEditMode" [disabled]="!testSuccessful" (click)="storeNewConnection()">Add Configuration</button>
TS:
this.adService.addAdConfiguration(this.adConfigurationObj, this.isEditMode).subscribe((response) => {
const msg: string = response.Status === ResultStatus.Success ? this.alerts.push(
{
msg: 'Configuration added successfully!',
type: 'success',
timeout: 3000
}) : response.Details;
});
}
this.router.navigate(['/configuration/groups-permissions'], { state: { isAdConfig: true } });
我想路由到这个路径(父组件)并在那里显示警报。
如何实现?
【问题讨论】:
标签: angular typescript components parent-child