Tuesday 15 April 2014

javascript - Make a controllers model available to the ApplicationController before it's loaded in Ember -



javascript - Make a controllers model available to the ApplicationController before it's loaded in Ember -

i trying access controller needed applicationcontroller (application needs practice), practicecontroller available after resource has been loaded through it's respective route-url visit. how, can create sure practicecontroller , it's content/model available @ times? specific, need flashcardarray available throughout application , @ times, when practice-route hasn't been visited, loaded yet. help!

here code:

app.router.map(function() { this.resource('signup'); this.resource('login'); this.resource('profile'); this.resource('practice'); this.resource('overview'); }); app.applicationroute = ember.route.extend({ model: function () { homecoming this.store.find('user'); } }); app.loginroute = ember.route.extend({ controllername: 'application', model: function () {} }); app.practiceroute = ember.route.extend({ model: function () { homecoming this.store.find('flashcards'); } }); //applicationcontroller app.applicationcontroller = ember.objectcontroller.extend({ needs: ['practice'], flashcardarray: ember.computed.alias('controllers.practice.flashcardarray'), currentuser: ember.computed.alias('model'), isloggedin: false } }); //practicecontroller app.practicecontroller = ember.objectcontroller.extend({ needs: ['application'], flashcardarray: ember.computed.alias('model'), currentuser: ember.computed.alias('controllers.application.currentuser') } }); // practice template feeded outlet of application template <script type="text/x-handlebars" id="practice"> <div class="content-padded"> {{#each object in flashcardarray}} <div class="card_wrapper"> <p><h1>{{{object.num_reference}}}</h1><p> <p>pinyin: {{{object.mandarin}}}</p> <p>def: {{object.definition}}</p> {{/each}} </div> </script>

i think if have info need throughout application, regardless of user's active route, need homecoming applicationroute:

app.applicationroute = ember.route.extend({ model: function () { homecoming { user: this.store.find('user'), flashcards: this.store.find('flashcards') }; } });

javascript ember.js

No comments:

Post a Comment