I am using openweathermap api to get current weather data and passing city argument in the api.
I am taking this ‘data’ value and displaying it on .hbs file.
Now I have added an input text field and button for entering city name.
How do I update the city name and model hook value(i.e data value is updated return from api fetch command) with the new value I take from .hbs file ?
Do I use controller?
How do I bind input to ember variable?
bind the city name input to a value on the controller (which of course means you should define a controller)
bind the controller city name value to a query param
add the query param to your route so the model hook re-fires when the query param changes
I’d suggest reading over a few pages in the guides:
component state and actions (since you’re working with a controller you can skip over all the stuff about “args” for now and just focus on the state which works the same way with a controller) and the input component which covers Ember’s built-in input component. I should note that the built-in component uses “two way binding” instead of “data down actions up” (a one way data flow) so if you want to use a native html input you can do that too