Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/431.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.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
Javascript 使用Ember.js和EmberFire生成表单_Javascript_Ember.js_Firebase_Emberfire - Fatal编程技术网

Javascript 使用Ember.js和EmberFire生成表单

Javascript 使用Ember.js和EmberFire生成表单,javascript,ember.js,firebase,emberfire,Javascript,Ember.js,Firebase,Emberfire,我有一个由{{each}}循环生成的表,它显示用户的名字和姓氏。我想添加一个删除按钮来删除该行上的记录。我还使用EmberFire连接Firebase 将该行中的数据与“删除”按钮关联的最佳方式是什么 以下是我掌握的一些相关代码: index.html controller.js 谢谢 您可以向IndexController添加删除操作: App.IndexController = Ember.ArrayController.extend({ actions: { register:

我有一个由{{each}}循环生成的表,它显示用户的名字和姓氏。我想添加一个删除按钮来删除该行上的记录。我还使用EmberFire连接Firebase

将该行中的数据与“删除”按钮关联的最佳方式是什么

以下是我掌握的一些相关代码:

index.html

controller.js


谢谢

您可以向IndexController添加删除操作:

App.IndexController = Ember.ArrayController.extend({
  actions: {
    register: function() {
      this.pushObject({
        'first' : this.get('firstName'),
        'last'  : this.get('lastName')
      });
    },
    delete: function(person) {
        this.content.removeObject(person);
    }
  }
})
然后将以下内容添加到index.html:

{{#each}}
  <tr>
    <td>
      {{this.first}}
    </td>
    <td>{{this.last}}</td>
    <td>
      <button {{action "delete" this}}>X</button>
    </td>
  </tr>
{{/each}}

您可以向IndexController添加删除操作:

App.IndexController = Ember.ArrayController.extend({
  actions: {
    register: function() {
      this.pushObject({
        'first' : this.get('firstName'),
        'last'  : this.get('lastName')
      });
    },
    delete: function(person) {
        this.content.removeObject(person);
    }
  }
})
然后将以下内容添加到index.html:

{{#each}}
  <tr>
    <td>
      {{this.first}}
    </td>
    <td>{{this.last}}</td>
    <td>
      <button {{action "delete" this}}>X</button>
    </td>
  </tr>
{{/each}}

是的,成功了!我假设我需要对每一行及其按钮进行某种手动数据绑定。我想我会用余烬的魔法:谢谢!是的,成功了!我假设我需要对每一行及其按钮进行某种手动数据绑定。我想我会用余烬的魔法:谢谢!
{{#each}}
  <tr>
    <td>
      {{this.first}}
    </td>
    <td>{{this.last}}</td>
    <td>
      <button {{action "delete" this}}>X</button>
    </td>
  </tr>
{{/each}}