我正在尝试在ember app的音符控制器中渲染“UsersView”。
users_view.js.coffee:
App.UsersView = Em.View.extend
templateName: "users/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')
和我希望在note的控制器上下文中的note路径中插入UsersView的模板:
模板:
<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 -->
如何将UsersController的内容绑定到此视图?
提前致谢
的更新 的 *
users_route.js.coffee
App.UsersRoute = Em.Route.extend
model: ->
App.User.find()
模板:
<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>
答案 0 :(得分:1)
您可以通过绑定用户视图的 controller 属性来解决此问题。
{{ view App.UsersView controllerBinding="App.UsersController" }}