컨트롤러에서 데이터를 가져 오는 방법을 알고 있습니다. 예각도 컨트롤러에서 데이터를 가져 오는 방법
controller.js
function RegisterCtrl($scope, $http, $location) {
$scope.form = {};
$scope.submitPost = function() {
$http.post('/register', $scope.form).
success(function(data) {
$location.path('/');
});
};
}
노선 /하는 index.js
app.post('/register', sessionHandler.handleSignup);
노선/
을 session.jsthis.handleSignup = function(req, res, next) {
"use strict";
// when i try to access into the controller by using "data" it said my "data"
// is not declare, what should i pass into `var data` = ?? in order to
// access the data from controller
var email = data.email,
confirmEmail = data.confirmEmail,
password = data.password,
confirmPassword = data.confirmPassword,
firstName = data.firstName,
lastName = data.lastName,
penName = data.penName,
publicUsername = data.publicUsername;
}
답변을 주셔서 감사합니다.이 3 개의 미들웨어를 앱에 포함시켜야합니까? app.use (express.bodyParser()); app.use (express.urlencoded()); app.use (express.json()) –
아니요. 이미 언급 한 두 가지뿐입니다. – sbruchmann