我正在尝试向我的控制器“matches.server.controller”名称 listTeams 添加一个新方法。我已经像这样向matches.server.route.js文件添加了一条新路由
'use strict';
/**
* Module dependencies.
*/
var users = require('../../app/controllers/users.server.controller'),
matches = require('../../app/controllers/matches.server.controller');
module.exports = function(app) {
// Match Routes
app.route('/matches/listTeams') <-- new route added here !!
.get(matches.listteams);
app.route('/matches')
.get(matches.list)
.post(users.requiresLogin, matches.create);
app.route('/matches/:matchId')
.get(matches.read)
.put(users.requiresLogin, matches.hasAuthorization, matches.update)
.delete(users.requiresLogin, matches.hasAuthorization, matches.delete);
// Finish by binding the matches middleware
app.param('matchId', matches.matchByID);
};
这是我的服务器控制器中的方法:
exports.listteams = function(req, res) {
res.json(1);
};
在matches.client.controller 我调用这样的方法:
$scope.listteams = function(){
$scope.teams = Matches.get('matches/listTeams').success(function(data){
var d = data;
}).error(function(data){
var d = data;
});
但是,当我调试时,我总是在匹配的列表方法中而不是在 listTeams 方法中我做错了什么?