我有一个类控制器CrudController.ts
import ibuild = require("../dataAccess/MongoDAO");
import dataAccess = require("../dataAccess/IGenericDAO");
export class CrudController {
protected model;
protected dao: dataAccess.IGenericDAO;
public constructor(model) {
this.model = model;
this.dao = new ibuild.MongoDAO(model);
console.log(this.dao);
}
public list(req, res) {
this.dao.findAll(res);
}
}
创建它的实例并将其传递给路由器,如下所示
'use strict';
var controllers = require('../controllers/CrudController');
var ibuildController = require('../controllers/ibuildController');
var mongoose = require('mongoose');
var Company = mongoose.model('Companies');
var controller = new controllers.CrudController(Company);
module.exports = function (app) {
// ibuild Routes
app.route('/company')
.get(controller.list);
};
但是每当我从控制器调用任何方法时,我都会在控制器中得到这个未定义的内容。
如何解决......