angularjs - How to get value from router request? -


i have created angular app. in app, want add search. this, have textbox , button. textbox name name="search"

i have method in api.

router.get('/allactivities',  (req, res) => {      activity.find({ name: req.body.search }, (err, activities) => {          if(err) {             res.json({success: false, message: err});         } else {             if(!activities) {                 res.json({success: false, message: 'no recent activities found'});             } else {                 res.json({success: true, activities: activities});             }         }     })  }); 

this request. in this, i'm trying text box value angular front end

activity.find({ name: req.body.search }, (err, activities) => 

this mongodb

but i'm not getting output. matter here i'm not getting value "req.body.search" used text box value. can tell me how this?

if put

activity.find({ name: 'roshini' }, (err, activities) => 

like this, i'm getting output. pretty sure i'm not getting textbox value method correctly, :/

html side

<input ng-model="search"> 

angular controller

$http({     method: 'get',     url: '/allactivities?search='+$scope.search }).then(function (response) {         $scope.activities = response.data || response     }, function (response) {         alert(response)     } ); 

and on backend access req.query.search or req.params.search rather req.body.search


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -