Answer the question
In order to leave comments, you need to log in
How to throw an event in the parent component?
There is a parent component in which there is a method and it must be called with certain parameters, there is also a child component and it defines the key parameters that are needed in the parent method.
Parent method code:
<app-auth [certs]="cert"
[certPassword] = "certPassword"
[certAlias] = "certAlias"
(sendCert)="sendCertTest(certAlias, certPassword)"
>
</app-auth>
sendCertTest(certAlias, certPassword): any {
...
}
<ng-container>
<mat-expansion-panel *ngFor="let cert of certs.arrCertInfo; let i = index">
...
<mat-form-field>
<mat-label>Пароль</mat-label>
<input matInput type="password" [(ngModel)]="certPassword">
</mat-form-field>
<button mat-stroked-button (click)="onSendCert(certs.arrAlias[i], certPassword)">Войти</button>
</div>
...
</ng-container>
@Input() certs: UserKey;
@Input() certPassword: any;
@Input() certAlias: any;
@Output() sendCert: EventEmitter<any> = new EventEmitter();
onSendCert(certAlias, certPassword): any {
this.certPassword = certPassword;
this.certAlias = certAlias;
this.sendCert.emit();
}
Answer the question
In order to leave comments, you need to log in
this.sendCert.emit();
- what's between the brackets, but at the moment nothing
gets here
(sendCert)="sendCertTest(certAlias, certPassword)"
certAlias, certPassword - will be undefined
Plus, the event has only one parameter.
And in general it is not clear why the same data is being sent back and forth.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question