Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/477.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
Javascript Angular-TypeError:path必须是$scope.formData的字符串?_Javascript_Node.js_Angularjs_Mongodb_Mongoose - Fatal编程技术网

Javascript Angular-TypeError:path必须是$scope.formData的字符串?

Javascript Angular-TypeError:path必须是$scope.formData的字符串?,javascript,node.js,angularjs,mongodb,mongoose,Javascript,Node.js,Angularjs,Mongodb,Mongoose,我有一个带有数字字段的表单: input type="number" class="form-control" placeholder="0" ng-model="formData.position" 当我提交表单时,.error函数响应500内部服务器错误,error:TypeError:path必须是字符串 $scope.createProduct = function() { // validate the formData (using our exentions.j

我有一个带有数字字段的表单:

input type="number" class="form-control" placeholder="0" ng-model="formData.position"
当我提交表单时,.error函数响应500内部服务器错误,error:TypeError:path必须是字符串

$scope.createProduct = function() {

        // validate the formData (using our exentions.js .filter) to make sure that something is there
        //if form is empty, nothing will happen
        if (!isEmptyObjectFilter($scope.formData)) {

                // call the create function from our service (returns a promise object)
                Emotions.create($scope.formData)

                        // if successful creation, call our get function to get all the new emotions
                        .success(function(data) {
                                $scope.formData = {}; // clear the form so our user is ready to enter another
                                $scope.products = data; // assign our new list of emotions
                        })
                        .error(function(data) {
                                console.log('Error: ' + data);
                        });
        }
};
formData可以是字符串和整数的混合体吗

以下是服务中的创建行:

    create : function(emotionData) {
        return $http.post('/api/emotions', emotionData);
    },
我有一个猫鼬模式,如下所示:

var ProductSchema = mongoose.Schema({
    title : String,
    position: Number
});
TypeError: path must be a string
    at Query.where (/Users/KK/Downloads/awaken/v16/node_modules/mongoose/lib/query.js:593:11)
    at Function.where (/Users/KK/Downloads/awaken/v16/node_modules/mongoose/lib/model.js:1040:18)
    at model.<anonymous> (/Users/KK/Downloads/awaken/v16/app/models/emotion.js:44:35)
...
错误的堆栈跟踪如下所示:

var ProductSchema = mongoose.Schema({
    title : String,
    position: Number
});
TypeError: path must be a string
    at Query.where (/Users/KK/Downloads/awaken/v16/node_modules/mongoose/lib/query.js:593:11)
    at Function.where (/Users/KK/Downloads/awaken/v16/node_modules/mongoose/lib/model.js:1040:18)
    at model.<anonymous> (/Users/KK/Downloads/awaken/v16/app/models/emotion.js:44:35)
...
这就是我在这里发布的内容:


正如错误消息所说,路径必须是字符串。你似乎在错误的地方寻找你的问题。您应该查看堆栈跟踪。问题很可能与试图访问文件有关。@barry johnson我应该在哪里查看/测试?当我将数字字段留空时,创建工作正常。您是否在控制台输出中获得任何类型的堆栈跟踪?您显示客户端代码,但不显示您在服务器上处理请求的操作,甚至不显示您的资源/服务代码,也不显示错误发生之前发生的服务器通信。@barry johnson添加了堆栈跟踪和其他一些信息。。有什么建议吗?我不是蒙哥人,所以在具体细节上可能没有多大用处。我会启动一个调试器,逐步检查您请求的服务器端发生了什么,因为这似乎是错误的根源。