How to pass values from child to parent component in Angular 4

后端 未结 2 1434
执笔经年
执笔经年 2020-12-16 19:01

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

2条回答
  •  猫巷女王i
    2020-12-16 19:40

    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

    
    

    parent.ts

    customFunc(data){
        this.totalcartval = data;
    }
    

    Also, there are other ways of communicating like subject in rxjs or by using shared service.

提交回复
热议问题