处理路由时出错:todos undefined不是函数

时间:2015-04-13 19:03:03

标签: javascript ember.js

我在显示模型数据步骤后尝试按照Ember网站(http://guides.emberjs.com/v1.10.0/getting-started/)上的TodoMVC演示应用程序时收到此错误。到目前为止,我的javascript代码是:

window.Todos = Ember.Application.create();

Todos.ApplicationAdapter = DS.FixtureAdapter.extend();

Todos.Router.map(function () {
    this.resource('todos', { path: '/' });
});

Todos.TodosRoute = Ember.Route.extend({
    model: function () {
        return this.store.find('todo');
    }
});

Todos.Todo = DS.Model.extend({
    title: DS.attr('string'),
    isCompleted: DS.attr('boolean')
});

Todos.Todo.FIXTURES = [
{
    id: 1,
    title: 'Learn Ember.js',
    isCompleted: true
},
{
    id: 2,
    title: '...',
    isCompleted: false
},
{
    id: 3,
    title: 'Profit!',
    isCompleted: false
}
];

1 个答案:

答案 0 :(得分:0)

我认为你的router.map错了。尝试以这种方式使用它 -

Todos.Router.map(
        function () {
                this.resource('todos', { path: '/' }, function () {
                this.route('active');
                this.route('completed');
        });
    });