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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.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 将数组2D添加到Ember.View的内容数组中_Ember.js - Fatal编程技术网

Ember.js 将数组2D添加到Ember.View的内容数组中

Ember.js 将数组2D添加到Ember.View的内容数组中,ember.js,Ember.js,我刚开始学习Ember,所以我想问一下如何将数组2D添加到Ember.View的内容数组中?E.x var IconMeaning = { OK: ['theme/dark/images/providers/ok.png', 'OK', 'Both'], Cancel: ['theme/dark/images/providers/delete.png', 'Cancel', 'Both'], Edit: ['theme/dark/images/providers/edit.png', 'Edi

我刚开始学习Ember,所以我想问一下如何将数组2D添加到Ember.View的内容数组中?E.x

var IconMeaning = {
OK:  ['theme/dark/images/providers/ok.png', 'OK', 'Both'],
Cancel: ['theme/dark/images/providers/delete.png', 'Cancel', 'Both'],
Edit: ['theme/dark/images/providers/edit.png', 'Edit', 'AdminOnly'],
Save: ['theme/dark/images/providers/save.png', 'Submit,Save', 'AdminOnly'],
Add: ['theme/dark/images/providers/plus_blue.png', 'Add,Create,Insert', 'Both'],
Remove: ['theme/dark/images/providers/remove.png', 'Remove,Delete', 'Both'],
Next: ['theme/dark/images/providers/next.png', 'Next,Continue', 'Both'],
Previous: ['theme/dark/images/providers/previous.png', 'Back,Previous', 'AdminOnly'],
Up: ['theme/dark/images/goback.png', 'Up a Level', 'Both'],
Info: ['theme/dark/images/providers/info.png', 'More Information', 'Both'],
Public: ['theme/dark/images/public.png', 'Make,Active/Public', 'AdminOnly'],
Private: ['theme/dark/images/private.png', 'Make,Inactive/Private', 'AdminOnly'],
Calendar: ['theme/dark/images/calendar.png', 'Select Date', 'AdminOnly'],
Download: ['theme/dark/images/providers/download.png', 'Download', 'Both'],
Reload: ['theme/dark/images/providers/reload.png', 'Reload,Refresh', 'AdminOnly'],
Print: ['theme/dark/images/providers/print.png', 'Print', 'Both'],
Unlink: ['theme/dark/images/providers/unlink.png', 'Unlink,Unregister', 'AdminOnly'],
AddToCart: ['theme/dark/images/providers/plus_green.png', 'Add to Cart', 'Both'],
Checkout: ['theme/dark/images/providers/checkout.png', 'Checkout', 'Both'],
Help: ['theme/dark/images/providers/help.png', 'Help', 'Both'],
VideoHelp: ['theme/dark/images/providers/helpbutton.png', 'Video Help', 'Both']
}


我想将它们添加到Ember.View中的内容数组中。非常感谢。

您可以为IconMeaning对象的每个“行”创建一个
Ember.Object
,其中包含您的键和值数组。然后使用
Ember.ArrayController
并使用
pushObject
将所有行推入其内容数组:

App.controller = Ember.ArrayController.create({
    content: []
});

for (var propertyName in IconMeaning) {
    var emberObj = Ember.Object.create({
        key: propertyName,
        values: IconMeaning[propertyName]
    });
    App.controller.pushObject(emberObj);
}
使用余烬绑定连接到视图:

App.view = Ember.View.extend({
    contentBinding: 'App.controller'
});
我在上创建了一个完整的工作示例