I got the solution as follows. Please let me know the short sentences in my code. I set the property for the Entry model when you call the entry route to make it visible.
HTML:
<script type="text/x-handlebars" > {{outlet}} </script> <script type="text/x-handlebars" id="entries"> {{#each controller }} {{#linkTo "entry" this}}{{name}}{{/linkTo}} <br /> {{#if visi}} <p>{{details}}</p> {{/if}} {{/each}} </script>
JAVASCRIPT:
App = Ember.Application.create(); App.Router.map(function(){ this.resource('entries', { path: '/'}, function() { this.resource('entry', { path: 'entry/:entry_id' }); }); }); App.Entry = Em.Object.extend({ id: null, name: null, details: null }); App.entries =[ App.Entry.create({ id: 1, name: 'entry 1', details: 'details 1' }), App.Entry.create({ id: 2, name: 'entry 2', details: 'details 2' }), App.Entry.create({ id: 3, name: 'entry 3', details: 'details 3' }) ]; App.EntriesRoute=Ember.Route.extend({ model:function() { return App.entries; } }); App.EntryRoute=Ember.Route.extend({ model:function(params) { var id=parseInt(params.entry_id); return App.entries.findProperty('id',id); }, setupController:function(controller,model){ App.entries.setEach('visi',false); model.set('visi',true); } });
Sincerely.
source share