ruby on rails - get a model from other controller in emberjs in view -


i got problem bigger project in ember, want information model when i'm in template not associated controller model.

i got these templates:

<script type="text/x-handlebars" data-template-name="community">    {{model.name}}    {{outlet}} </script>  //users subroute community <script type="text/x-handlebars" data-template-name="communityusers">    //assume want display community here like:    {{community.id}}    {{#each user in model}}      <li>{{user.name}}</li>    {{/each}} </script> 

in routes fetch appropriate models community got 1 community , in communityusers have array users

does know best solution this?

i got problem bigger project in ember, want information model when i'm in template not associated controller model.

assuming communities this:

app.communityroute = ember.route.extend({   model: function() {     return app.community.find();   } }); 

further assuming want have access controller not related communitycontroller (which get's it's content set after model hook returns) use needs api , define dependance it

app.communityuserscontroller = ember.objectontroller.extend({   // here dependence definition   needs: ['community'],   // create observer returns community want   // i've chosen first 1   choosencommunity: function() {     return this.get('controllers.community').objectat(0);   }.observes('controllers.community') }); 

so in communityusers template able access properties

<script type="text/x-handlebars" data-template-name="communityusers">    //assume want display community here like:    {{choosencommunity.id}}    {{#each user in choosencommunity.users}}      <li>{{user.name}}</li>    {{/each}} </script> 

and best of this, stay date since it's bound.

hope helps.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -