181
rated 0 times
[
187]
[
6]
/ answers: 1 / hits: 22581
/ 4 Years ago, thu, september 24, 2020, 12:00:00
I have two components. Component A which is the parent and component B which is the child.
Component A looks like this:
A.html
<nb-box [onCreditChange]="onCreditChange"></nb-box>
A.ts
onCreditChange($event) { console.log($event) }
The function from component A is transferred to B.
Component B looks like this
B.html
<div class="box">
<nb-switch (onChange)="onCreditChange($event)"></nb-switch>
</div>
B.ts (part of this component)
import { Component, Input, NgModule, EventEmitter, Output} from '@angular/core';
export class Box extends BoxBase {
@Output() onCreditChange: EventEmitter<any> = new EventEmitter()
}
I get an error when calling the function
core.js:6241 ERROR TypeError: ctx.onChange is not a function
Do you know how to fix it?
More From » angular