Skip to content Skip to sidebar Skip to footer

Pass A Nodejs Express Object To Angularjs 1.6

I have a working NodeJS API using Express. I am confused how to properly pass in a parameter from NodeJS to AngularJS in order to retrieve the data for the page. Note: My question

Solution 1:

You can use template literals: in your url string.

functionDetailPageController($http, id = 5761233819297931) {
var vm = this;
$http({
  url: `/detail/json/${id}`, //HARD-CODED ID HOW TO PASS IN DYNAMICALLY?method: 'GET'
}).then(function (response){
vm.book = response.data;
console.log('API worked', response);
},function (error){
console.log('API error: ', error);
});

}

Post a Comment for "Pass A Nodejs Express Object To Angularjs 1.6"