last day (15 days later) » 

5:19 AM
0
Q: Ember Octane Upgrade How to pass values from component to controller

J WeezyUpgrade from Ember < 3.15 to >= 3.15. How do I pass form values from a controller into a component? I cannot begin to explain the number of diagnostic combinations attempted and their corresponding errors received. So, I figure it best to ask how it should be done correctly? Is Glimmer involved?...

 
@GokulKathirvel I have updated my answer - I was missing a few files. Thank you for catching that.
What I am trying to say is that this works in Ember 3.12. But, 3.17 Octane introduces changes. What should this code look like in 3.17?
I have updated the question to include native classes and decorators. This is what I have attempted so far, but it is not working.
 
Ok, from a brief look I may suggest 1) instead of {{on "submit" this.changePassword}} pass it like @changePassword={{this.changePassword}} so simply pass the action as a parameter and 2) then in your component call it not as this.onsubmit (I guess Ember is right here saying it's not defined) but rather as this.args.changePassword. If that helps I'd make that an answer.
 
@AndreyStukalin By changing to @changePassword={{this.changePassword}} then the component receives null data. Although, the onsubmit is not a function error goes away. But, now I don't have my data.
 
@JWeezy what do you mean by "null data"? The @changePassword function is null?
 
@AndreyStukalin in the component, the changePassword(ev) ev comes in undefined (null). For example, the breakpoint, this.oldPassword = ev.oldPassword; is undefined
 
5:19 AM
Ok, and what if you change your onsubmit= to {{on "submit"}} like described here guides.emberjs.com/release/components/looping-through-lists/‌​…?
 
I just changed that back before I posted the bounty and it did not work either. I was receiving the data earlier, but now it is not coming and it is frustrating.
 
Hmm, I am not a huge expert in Ember, just doing the process of octanifying myself
but I'd rather choose the pair @action attribute + {{on "submit"}} because this action stuff is pretty weird
ah, and another one
you don't have to use the ev. In the action use this.oldPassword etc
Like in the sample with this list
they do the same. Check this out and I'll have some breakfast meanwhile
 
5:43 AM
The main difference between my question and the guide you posted is that I am then trying to call the controller. I need an end to end solution to get the data from the form and push it to my web API.
I'm calling it for tonight - I need to get some sleep.
 

last day (15 days later) »