I am working in an Angular4 application ,In I\'m trying to pass values from child component to parent component .I have implemented something but I can\'t get the output as
In angular 4 you can use @Input, @Output decorators for values or Emit the data.
Please refer https://angular.io/guide/component-interaction
You are emitting the value by using event emitter sendCount
.
You have to receive it in parent component by using child component like this:
parent.html
<app-my-cart (sendCount)="customFunc($event)"></app-my-cart>
parent.ts
customFunc(data){
this.totalcartval = data;
}
Also, there are other ways of communicating like subject
in rxjs
or by using shared service.