2016-03-15 68 views
0

我是新来的角js。我正在使用平均堆栈方法。我controller.js文件具有下面的代码:Angular JS服务器回复状态为404(Not Found)

var myApp = angular.module('myApp',[]); 
myApp.controller('MyCtrl',['$scope','$http',function MyCtrl($scope,$http){ 
    console.log("hello from controller"); 
    $http.get('/pointList'); 

    person1 = { 
     name:'roni', 
     email:'[email protected]', 
    }; 
    person2 = { 

     name:'abhijit', 
     email:'[email protected]', 


    }; 
    person3 = { 
     name: 'amit', 
     email: '[email protected]', 

    }; 
    var pointList =[person1,person2,person3]; 
    $scope.pointList = pointList; 
}]); 

我server.js具有下面的代码

var express = require('express'); 
var app = express(); 


app.use(express.static(__dirname +'/public')); 

app.post('/pointList',function(req, res){ 
    console.log("Hey ! received get request"); 

}); 

app.listen(3000); 
console.log("server running on port 3000"); 

我无法接受的GET请求。 谢谢

+0

你有一个页面,在通过'http://本地主机:3000/pointList'? – dgig

回答

1

您正在向前端发送get请求,同时在后端接收到post调用。更改app.postapp.get

app.post('/pointList',function(req, res){ 
    console.log("Hey ! received get request"); 
}); 
0
app.get('/pointList',function(req, res){ 
    console.log("Hey ! received get request"); 

}); 

尝试改变上述

+0

不,没有工作 – Rays

+0

你有什么错误吗?如果不是,你会得到什么回应? –

+0

错误:无法加载资源:服务器响应状态为404(未找到) – Rays

相关问题