David Villa
David Villa

Reputation: 107

Render a view in another controller - ember

I am trying to render "UsersView" in the note´s controller of a ember app.

users_view.js.coffee:

App.UsersView = Em.View.extend

  templateName: "users/users"

template users:

{{#if isEmpty }}

<h5>No hay Users</h5>

{{else}}

<ul class="nav nav-list">
  <li class="nav-header">list</li>
    {{#each content}}
     <li>{{  name }}</li>
    {{/each}}
</ul>
{{/if}}

users_controller.js.coffee:

App.UsersController = Em.ArrayController.extend

  isEmpty:( ->
    @get('length') == 0
  ).property('length')

and the template where i want to insert the UsersView in note´s path under the note´s controller context:

template:

<div class="container" style="margin-top: 30px">
  <div class="row">
    <div class="span3">
      <div class="well sidebar-nav">
        <h3>List of Notes</h3>
          {{ outlet }}

        <h3>List of Users</h3>
          {{ view App.UsersView }}      #HOW CAN I BIND THE USERS CONTROLLER CONTENT TO THIS VIEW ??
      </div>
      <!--/.well -->
    </div>

    <div class="span9">
    </div>
    <!--/span-->
  </div>
  <!--/row-->

</div> <!-- /container -->

How can i bind the UsersController´s content to this view ??

thanks in advance

UPDATE*

users_route.js.coffee

App.UsersRoute = Em.Route.extend

  model: ->
    App.User.find()

template:

<div class="container" style="margin-top: 30px">
  <div class="row">
    <div class="span3">
      <div class="well sidebar-nav">
        <h3>Notes</h3>
          {{ outlet }}

        <h3>Users</h3>
        {{view App.UsersView controllerBinding="App.UsersController"}}
      </div>
      <!--/.well -->
    </div>

    <div class="span9">
    </div>
    <!--/span-->
  </div>
  <!--/row-->

</div>

Upvotes: 0

Views: 814

Answers (1)

Thomas Brus
Thomas Brus

Reputation: 941

You can solve this by binding the controller property of the users view.

 {{ view App.UsersView controllerBinding="App.UsersController" }}

Upvotes: 1

Related Questions