Javascript 什么';Ember.js中ArrayController的作用是什么?

Javascript 什么';Ember.js中ArrayController的作用是什么?,javascript,model-view-controller,ember.js,Javascript,Model View Controller,Ember.js,文档中有一个将ArrayController与此模板一起使用的示例: {{#each MyApp.listController}} {{firstName}} {{lastName}} {{/each}} 以下是ArrayController的使用方式: MyApp.listController = Ember.ArrayController.create(); $.get('people.json', function(data) { MyApp.listController.se

文档中有一个将
ArrayController
与此模板一起使用的示例:

{{#each MyApp.listController}}
  {{firstName}} {{lastName}}
{{/each}}
以下是
ArrayController
的使用方式:

MyApp.listController = Ember.ArrayController.create();

$.get('people.json', function(data) {
  MyApp.listController.set('content', data);
});
这与使用这样的普通数组有什么不同

MyApp.listController = [];

$.get('people.json', function(data) {
  MyApp.set('listController', data);
});

如果不需要控制器的行为,可以使用普通数组

ArrayController包装数组,并添加一些其他属性,例如可排序的mixin。 你可以在这里看到:


在ember.js文档中说:

(http://docs.emberjs.com/symbols/Ember.ArrayController.html)

使用ArrayController的优点是只需设置 打开视图绑定一次;要更改显示内容,只需交换 输出控制器上的内容属性

它在后台使用数组,仅对使用数组的方法有帮助:

虽然您绑定到控制器,但是 控制器将通过任何方法或属性传递给 底层数组