You can use event handlers to send actions from components to your application.
Syntax
{{comp_name action = "name_of_action"}}
Example
The example given below specifies sending actions from components to your application. Create a component with the name comp-yield and open the component template file comp-yield.js created under app/components/ with the following code −
import Ember from 'ember'; export default Ember.Component.extend ({ actions: { compFunc: function () { this.set('title', "Hello...Welcome To Adglob..."); //sendAction() method sends the specified action when the component is used in a template this.sendAction(); } } });
Open the comp-yield.hbs file created under app/templates/components/ and enter the following code −
<h2>Sending Actions to a Component</h2> <input type = "button" value = "Click Here" {{action "compFunc"}} /><br/> <p><b>{{title}}</b></p> {{yield}}
Create the application.hbs file and add the following code −
{{comp-yield title = title action = "compFunc"}} {{outlet}}
Previous Page:-Click Here