Angular2: child component access parent class variable/function

前端 未结 5 1050
夕颜
夕颜 2020-12-02 11:47

I have a variable in the parent component that might be changed by child, parent will be using this variable in the view and thus has to propagate changes.

i         


        
5条回答
  •  心在旅途
    2020-12-02 12:44

    Basically you can't access variables from parent directly. You do this by events. Component's output property is responsible for this. I would suggest reading https://angular.io/docs/ts/latest/guide/template-syntax.html#input-and-output-properties

提交回复
热议问题