Akhil
Akhil

Reputation: 443

Notify parent property from child which is dom-repeating

i have initialized property buyitem in the child component, and calling order function to call it.

order() { this.buyitem = "change";}

and it is changing in the component level. and in the parent component it is not reflecting. I added reflectToAttribute: true and notify:true in both components.

Upvotes: 1

Views: 417

Answers (1)

Cappittall
Cappittall

Reputation: 3441

In order to reflect to parent value upward changes, let say you are in parent-app.html example, use {{...}} for two way data binding.( not [[...]])

<child-elem buyitem = "{{buyitem}}"></child-elem> 

into child-elem element declare property notify:true will be enough:

static get properties() { return { 
       buyitem:{
           type:String,
           notify:true
             }

but also use this.set instead this.buyitem = "change"

this.set('buyitem', 'change');  // to observable changes. 

Upvotes: 2

Related Questions