- EmberJS Tutorial
- EmberJS - Home
- EmberJS - Overview
- EmberJS - Installation
- EmberJS - Core Concepts
- Creating and Running Application
- EmberJS - Object Model
- EmberJS - Router
- EmberJS - Templates
- EmberJS - Components
- EmberJS - Models
- EmberJS - Managing Dependencies
- EmberJS - Application Concerns
- EmberJS - Configuring Ember.js
- EmberJS - Ember Inspector
- EmberJS Useful Resources
- EmberJS - Quick Guide
- EmberJS - Useful Resources
- EmberJS - Discussion
Template Modifying Action's first Parameter
You can modify the action's first parameter by specifying a value option for the {{action}} helper.
Syntax
<input type = "text" value = {{name}} onblur = {{action "action-name"}} />
Example
The example given below shows modifying the action's first parameter by using the {{action}} helper with value option. Create a new component and name it as post-action.js with the following code −
import Ember from 'ember'; export default Ember.Component.extend({ actions: { actionFirstParameter(newName) { document.write('Name is:'+' '+newName); } } });
Open the post-action.hbs file created under app/templates/ with the following code −
<label>Enter the name:</label> <input type = "text" value = {{yourName}} onblur = {{action "actionFirstParameter" value = "target.value"}} /> {{outlet}}
Next, open the application.hbs file created under app/templates/ with the following code −
{{post-action}} {{outlet}}
Output
Run the ember server and you will get the input box to enter the value −
It will display the value of the input field, where the user has mentioned as shown in the screenshot below −
emberjs_template.htm
Advertisements