Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.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
Javascript 余烬罐';在模型上找不到find()方法_Javascript_Ember.js - Fatal编程技术网

Javascript 余烬罐';在模型上找不到find()方法

Javascript 余烬罐';在模型上找不到find()方法,javascript,ember.js,Javascript,Ember.js,Ember似乎找不到我在属性模型上实现的findAll()和find()方法。以下是我得到的错误: TypeError: App.Property.findAll is not a function 及 我的路由器设置如下: App.Router = Ember.Router.extend({ showProperty: Ember.Route.transitionTo('property'), root: Ember.Route.extend({ home:

Ember似乎找不到我在属性模型上实现的
findAll()
find()
方法。以下是我得到的错误:

TypeError: App.Property.findAll is not a function

我的路由器设置如下:

App.Router = Ember.Router.extend({
    showProperty: Ember.Route.transitionTo('property'),
    root: Ember.Route.extend({
        home: Ember.Route.extend({
            route: '/',
            connectOutlets: function(router) {
                router.get('applicationController').connectOutlet('home', App.Property.findAll());
            }
        }),
        property: Ember.Route.extend({
            route: '/property/:property_id',
            connectOutlets: function(router, property) {
                router.get('applicationController').connectOutlet('property', property);
            },
        }),
    })
});
这是我的模型:

App.Property = Ember.Object.extend({
    id: null,
    address: null,
    address_2: null,
    city: null,
    state: null,
    zip_code: null,
    created_at: new Date(0),
    updated_at: new Date(0),
    find: function() {
        // ...
    },
    findAll: function() {
        // ...
    }
});
我做错了什么?这些方法应该放在属性模型上还是放在其他地方?我应该重写
反序列化()
方法而不是使用
find()
?但即使我使用该变通方法
findAll()


谢谢你的帮助

应该在
researclass
中声明
find
findAll
方法,而不是在
extend
中声明,因为您希望定义类方法,而不是实例方法。 例如:

App.Property = Ember.Object.extend({
    id: null,
    address: null,
    address_2: null,
    city: null,
    state: null,
    zip_code: null,
    created_at: new Date(0),
    updated_at: new Date(0)
});

App.Property.reopenClass({
    find: function() {
        // ...
    },
    findAll: function() {
        // ...
    }
});
App.Property = Ember.Object.extend({
    id: null,
    address: null,
    address_2: null,
    city: null,
    state: null,
    zip_code: null,
    created_at: new Date(0),
    updated_at: new Date(0)
});

App.Property.reopenClass({
    find: function() {
        // ...
    },
    findAll: function() {
        // ...
    }
});