samedi 4 mars 2017

How to create action for my own component

I am creating one ember app. Flow is like " page1 displays list of feeds item and clicking on any of the feed will take user to page2 showing details about that feed"

What i am doing: i have one component named app-feed. Template is as below

<div onclick=>

  <!--  <a href="feed/"> --> <!--</a>-->
    
            
                <img class="profile-small"  src="http://ift.tt/2mR8uu2" alt="" />
            
            <span class="tag-sm like-box">
                 
                
            </span>
    
    
        
        
        

    

</div>

component.js is as below import Ember from 'ember';

export default Ember.Component.extend({
    actions:{
      click(feed){
        console.log("Click event fired:"+feed.id); //Output is correct in console
        this.sendAction("onClick", feed); //sending onClick Action
      }
    }
});

I'm populating list of this component in one of my route. Template is as below


<div class="content">
  <div class="row">
      
         
      
   </div>
 </div>

route.js is as below import Ember from 'ember';

export default Ember.Route.extend({
    store: Ember.inject.service(),

    model(){
        //Populating module. Works just fine
    } ,
    actions:{
      getDetails(feed){
        console.log("Getting details of "+feed.id);
      }
    }   
});

I have defined getDetails action as mentioned in my template.js of the route still i am getting below error

""Assertion Failed: An action named 'getDetail' was not found in (generated feed.index controller)""

feed.index is my route.

I used same method and modified paper-chip's source to get action corresponding to click on paper-chip's item which worked. But i am not able to do same in my own component. Please let me know what is missing




Aucun commentaire:

Enregistrer un commentaire