Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 无法发布/api/_Angularjs_Node.js_Mongodb_Mean Stack - Fatal编程技术网

Angularjs 无法发布/api/

Angularjs 无法发布/api/,angularjs,node.js,mongodb,mean-stack,Angularjs,Node.js,Mongodb,Mean Stack,我正在尝试使用AngularJS和NodeJS的mongoose模块获取一个对象文件发送到服务器。我确实得到了对象,但由于无法发布/api/appointment/new错误,它没有被发送到服务器 这是我的HTML文件: <div class="row"> <div class="col-sm6 col-sm-offset-3"> <div class="row"> <strong>D

我正在尝试使用AngularJS和NodeJS的mongoose模块获取一个
对象
文件发送到服务器。我确实得到了
对象
,但由于
无法发布/api/appointment/new
错误,它没有被发送到服务器

这是我的
HTML
文件:

<div class="row">
        <div class="col-sm6 col-sm-offset-3">
            <div class="row">
            <strong>Date:</strong>
                <label>
                    <input type="text" type="date" ng-model="new.date" class="form-control">
                </label>
                <strong>Name Surname:</strong>
                <label>
                    <input type="text" ng-model="new.nameSurname" class="form-control">
                </label>
            </div>
            <div class="row">
                <strong>Case:</strong>
                <label>
                    <input type="text" ng-model="new.description" class="form-control">
                </label>
            <strong>Contact number:</strong>
                <label>
                    <input type="tel" ng-model="new.contactNumber" class="form-control">
                </label>
            <button ng-click='createAppointment()'>Create appointment!</button>
            </div>
        </div>
    </div>
服务器控制器:

var mongoose;
mongoose = require('mongoose');
var appointment;
appointment = require('../datasets/appointment.js');

module.exports.create = function(req, response) {
    console.log(req.body)
};
(function() {
    //noinspection JSUnresolvedFunction
    angular.module('dentalAdviser')
        .controller('appointmentController', ['$scope', '$state', '$http', function ($scope, $state, $http) {

            $scope.createAppointment = (function() {
                console.log($scope.new);
                $http.post('api/appointment/new', $scope.new).success(function (response) {
                }).error(function (error) {
                    console.log(error);
                })
            });
        }])
}());
应用程序控制器:

var mongoose;
mongoose = require('mongoose');
var appointment;
appointment = require('../datasets/appointment.js');

module.exports.create = function(req, response) {
    console.log(req.body)
};
(function() {
    //noinspection JSUnresolvedFunction
    angular.module('dentalAdviser')
        .controller('appointmentController', ['$scope', '$state', '$http', function ($scope, $state, $http) {

            $scope.createAppointment = (function() {
                console.log($scope.new);
                $http.post('api/appointment/new', $scope.new).success(function (response) {
                }).error(function (error) {
                    console.log(error);
                })
            });
        }])
}());
和对象的数据集:

var mongoose = require('mongoose');
    module.export = mongoose.model('appointment', {
        nameSurname: String,
        date: String,
        description: String,
        contactNumber: String
    });
这:

应该是:

app.post('/api/appointment/new', newAppointment.create);

我不敢相信我错过了这个。。。非常感谢。