0

我使用 EmberJS 重新创建了 TodoMVC,完成后,我尝试将 ApplicationAdapter 更改为 FirebaseAdapter。但随后应用程序停止工作,我收到此错误:

Error while loading route: undefined 

这是我正在使用的版本

Ember      : 1.5.0
Ember Data : 1.0.0-beta.7+canary.b45e23ba
Handlebars : 1.3.0
jQuery     : 2.1.0

您可以在github上查看代码, 但这里有一些文件内容。

使用此代码,它可以工作

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

但是当我把它改成这个时,它停止工作并且我得到了错误:

Todos.ApplicationAdapter = DS.FirebaseAdapter.extend({
    firebase: new Firebase('https://glaring-fire-8506.firebaseio.com')
});

我有 TodosController 和 TodoController,这是我的路由器文件

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

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

Todos.TodosIndexRoute = Ember.Route.extend({
    model: function () {
        return this.modelFor('todos');
    },

    renderTemplate: function (controller) {
        this.render('todos/index', {
            controller: controller
        });
    }
});

Todos.TodosActiveRoute = Todos.TodosIndexRoute.extend({
    model: function () {
        return this.store.filter('todo', function (todo) {
            return !todo.get('isCompleted');
        });
    }
});

Todos.TodosCompletedRoute = Todos.TodosIndexRoute.extend({
    model: function () {
        return this.store.filter('todo', function (todo) {
            return todo.get('isCompleted');
        });
    }
});

编辑:当我将 todos JSON 对象添加到 Firebase 时,它​​可以正常工作。但我真的很想了解这个问题。

4

1 回答 1

0

问题在于 emberFire 没有处理空/不存在的集合。这已在 emberFire 存储库中得到修复。

Github 问题:https ://github.com/firebase/emberFire/issues/39

于 2014-04-20T00:19:00.930 回答