javascript - Angular - TypeError: path must be a string for $scope.formData? -
i have form has number field:
input type="number" class="form-control" placeholder="0" ng-model="formdata.position"
and when submit form, .error function responds 500 internal server error, error: typeerror: path must string
$scope.createproduct = function() { // validate formdata (using our exentions.js .filter) make sure there //if form empty, nothing happen if (!isemptyobjectfilter($scope.formdata)) { // call create function our service (returns promise object) emotions.create($scope.formdata) // if successful creation, call our function new emotions .success(function(data) { $scope.formdata = {}; // clear form our user ready enter $scope.products = data; // assign our new list of emotions }) .error(function(data) { console.log('error: ' + data); }); } };
can formdata mix of strings , integers?
here's create line in service:
create : function(emotiondata) { return $http.post('/api/emotions', emotiondata); },
i have mongoose schema looks this:
var productschema = mongoose.schema({ title : string, position: number });
the stack trace error looks this:
typeerror: path must string @ query.where (/users/kk/downloads/awaken/v16/node_modules/mongoose/lib/query.js:593:11) @ function.where (/users/kk/downloads/awaken/v16/node_modules/mongoose/lib/model.js:1040:18) @ model.<anonymous> (/users/kk/downloads/awaken/v16/app/models/emotion.js:44:35) ...
which looks lead line (44?) of emotion.js file:
mongoose.model("product").where({_id: {$ne: doc._id}, position: doc.position}).count( function (err, count) {
and posting here:
Comments
Post a Comment