I have designed the ember app in which I have photos feed page.Each pic contains like button,like test and value corresponding to it.Now when I click on the like button.It should change like pic,color of text like,and its value.it is same as Facebook like button.I am not sure how to implement it in ember
feed.js
{{#each feedResult as |feed|}}
<div class="scale">
<img id = "image1" src = "{{feed.feedPhotos.0.photo_url}}"/>
<div class="transhifive">
{{#if feed.feedPhotos.0.is_liked}}
<a href = "#" {{action 'unlike'}} >
<img src = "images/ic-unlike-yellow.png">
<p>Hi Five! |</p>
</a>
{{else}}
<a href ="#" {{action 'like'}}>
<img src = "images/ic-like-white.png"/>
<p>Hi Five! |</p>
</a>
{{/if}}
<p>{{feed.feedPhotos.0.numlikes}}</p>
</div>
{{/each}}
controller.js
export default Ember.Controller.extend({
session:service('session'),
feedResult:Ember.computed('model',function() {
"SOME MANIPULATION WITH MODEL DATA"
}),
hifive(){
this.incrementProperty('feed.feedPhotos.0.numFives');
}
}
});
I thought this will atleast increase the like value but it is also throwing error.
Uncaught Error: Property set failed: object in path "feed.feedPhotos.0" could not be found or was destroyed
How should implement it so that it work exactly like facebook "like button"?
Aucun commentaire:
Enregistrer un commentaire