ember.js - How can I delete a chat message with Emberfire? -


i've created action add messages firebase, can't seem figure out how remove specific message. here new message controller far:

import ember 'ember';  export default ember.controller.extend({ //define actions here actions: {     addmessage: function() {         //createrecord creates new instance of message model         var newmessage = this.store.createrecord('message', {             //this gets info form fields value             name: this.get('name'),             body: this.get('body')         });         //this saves data store , firebase         newmessage.save();         //this resets fields blank again         this.setproperties({             name: '',             body: ''         });     }   } }); 

and message controller remove action

import ember 'ember';  export default ember.controller.extend({ actions: {     deletemessage: function(id) {         var msg = this.store.find('message', id, {             //this gets info form fields value             name: this.get('name'),             body: this.get('body')         });         //this deletes data store , firebase         msg.remove();     } } }); 

and here's template

<div class="new-msg-link">     {{#link-to 'messages.new'}}add new message{{/link-to}} </div>  {{outlet}}  {{#each message in model}}     <div class="each-msg">         {{message.name}}: {{message.body}}         <button {{action 'deletemessage'}}>delete</button>     </div> {{/each}} 

i'm not sure how pass id parameter in action correctly , how firebase correctly. suggestions great! thanks


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -