{{#each}} Handlebars Helper在App.controller.content上工作但不在App.controller上工作

时间:2013-03-21 23:16:50

标签: javascript ember.js handlebars.js

我有以下新生的Ember应用程序:

RTorrent = Ember.Application.create();

RTorrent.Torrent = Ember.Object.extend({
    title: null
});

RTorrent.torrentController = Ember.ArrayController.create({
    content: [],
    init: function() {
        var torrent = RTorrent.Torrent.create({
            title: 'Test'
        });
        this.pushObject(torrent);
    }
});

使用这个有效的HTML:

<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="lib/handlebars.js"></script>
    <script src="lib/ember-1.0.0-rc.1.js"></script>
    <script src="js/rtorrent.js"></script>
</head>
<body>
<script type="text/x-handlebars">
    <table>
        <tr>
            <th>
                Title
            </th>
        </tr>
            {{#each RTorrent.torrentController.content}}
            <tr>
                <td>
                    {{title}}
                </td>
            </tr>
            {{/each}}
    </table>
</script>
</body>
</html>

我的理解(基于http://www.appliness.com/flame-on-a-beginners-guide-to-ember-js/)是RTorrent.torrentController应该有效(没有.content)。我的假设错了吗?如果没有,为什么上述工作.content已删除?

0 个答案:

没有答案