Angularjs meanjs到服务器控制器的路由
我正在尝试向控制器“matches.server.controller”名称列表中添加一个新方法。 我向matches.server.route.js文件添加了一个新路由,如下所示Angularjs meanjs到服务器控制器的路由,angularjs,node.js,express,meanjs,Angularjs,Node.js,Express,Meanjs,我正在尝试向控制器“matches.server.controller”名称列表中添加一个新方法。 我向matches.server.route.js文件添加了一个新路由,如下所示 'use strict'; /** * Module dependencies. */ var users = require('../../app/controllers/users.server.controller'), matches = require('../../app/controllers/m
'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);
};
在matches.client.controller中,我调用如下方法:
$scope.listteams = function(){
$scope.teams = Matches.get('matches/listTeams').success(function(data){
var d = data;
}).error(function(data){
var d = data;
});
然而,当我调试时,我总是使用匹配的列表方法,而不是ListTeam方法
我做错了什么?可能是因为您复制了路径名
'/matches/'
后面的所有参数都由
app.route('/matches/:matchId')
.get(matches.read)
.put(users.requiresLogin, matches.hasAuthorization, matches.update)
.delete(users.requiresLogin, matches.hasAuthorization, matches.delete);
并感知'/:matchId'
在您的情况下:找到id为“ListTeam”的me团队
尝试将路径从匹配项
重命名为smth或其他类似项
module.exports = function(app) {
// Match Routes
app.route('/smthelse_not_matches/listTeams') <-- new route added here !!
.get(matches.listteams);
module.exports=函数(应用程序){
//赛道
app.route('/smthelse_not_matches/listTeams')据我所知,您正在使用“为什么使用此控制器?”从MongoDB接收团队阵列?我之所以“使用此控制器”是因为团队不在MongoDB中,但我想从web服务获取它们。
module.exports = function(app) {
// Match Routes
app.route('/smthelse_not_matches/listTeams') <-- new route added here !!
.get(matches.listteams);