Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ember.js 如何将按钮连接到其他控制器_Ember.js - Fatal编程技术网

Ember.js 如何将按钮连接到其他控制器

Ember.js 如何将按钮连接到其他控制器,ember.js,Ember.js,在模板中,我遍历所有用户。从每个用户我想将一个按钮连接到UserController(singluar)中的xyz功能。我必须如何使用{{action}}才能做到这一点?现在,我所有的尝试都在userscoontroller中结束 index.html <script type="text/x-handlebars" data-template-name="users"> <table> {{#each model}} <tr>

在模板中,我遍历所有
用户
。从每个
用户
我想将一个按钮连接到
UserController
(singluar)中的
xyz
功能。我必须如何使用
{{action}}
才能做到这一点?现在,我所有的尝试都在
userscoontroller
中结束

index.html

<script type="text/x-handlebars" data-template-name="users">
  <table>
    {{#each model}}
      <tr>
        <td>{{lastName}}</td>
        <td><button {{action "xyz" this}}>Xyz</button></td>
      </tr>
    {{/each}}
  </table>
</script>

一种解决方案是使用
每个
助手的
itemController=“user”
属性。这样,目标控制器应该是每个用户的UserController实例

{{#each model itemController="user"}}
  <tr>
    <td>{{lastName}}</td>
    <td><button {{action "xyz" this}}>Xyz</button></td>
  </tr>
{{/each}}
{{#每个模型itemController=“user”}
{{lastName}}
Xyz
{{/每个}}
{{#each model itemController="user"}}
  <tr>
    <td>{{lastName}}</td>
    <td><button {{action "xyz" this}}>Xyz</button></td>
  </tr>
{{/each}}