0
votes

I have a controller ApplicationController with controllerInt and controllerString properties.

And I have a component RedSquareComponent with componentInt and componentString properties.

I bind controllerInt and controllerString to componentInt and componentString via hbs-template, componentString=controllerString="VALUE FROM CONTROLLER".

In RedSquareComponent I also have .on('init') method which set "SET ON INIT" value to componentString.

I've added an action to component to handle click on some object (red square) and set some value (for example, 1) to componentInt.

But when this action works -- componentString also changes (I don't know why), and become equal to "VALUE FROM CONTROLLER".

Is it a really expected behaviour?

The same code works fine on Ember 12.4, but I have checked it on several 13.* versions - it doesn't work.

https://jsfiddle.net/AlexeyBedonik/a23ev98w/3/

1

1 Answers

0
votes

In your case, if you just change .on('init') part to .on('didInsertElement') it will fix your problem.(that means it will update both controller and component componentString property to 'SET ON INIT'.)
But you should not change values on a parent that are rendered already is deprecated. so you will get deprecation warning.

To get more info about this issue/bug follow this discussion.

It's good to follow/understand below concepts.

1) Passing properties to component by default it is two-way data binding
2) To update data always follow the Data Down Actions Up priniciple (DDAU)