To create common form controls, input
helpers can be used. This recipe will go over how to use them in our Ember applications.
The most common input
helper is {{input}}
. It wraps around the Ember.TextField
view and is almost identical to the traditional <input>
HTML element.
Create a new project. In the
app/templates
folder, open theapplication.hbs
file and add aninput
helper:// app/templates/application.hbs <h2 id="title">Welcome to Ember</h2> <br> <br> {{input value='Hello World'}}
This
input
helper is very simple; all it does is set the value of the textbox tohello world
. It is surrounded by double curly braces and supports the normal input attributes.When rendered, it will look as follows:
<h2 id="title">Welcome to Ember</h2> <br> <br> <input type="text" value="Hello World"/>
If needed, we can assign properties to the
input
helper.