I have created a nodejs application that will read all the databases in my mongo Db. Which i am able to do in the console. However, when i try too get the data parsed to a json object and dispaly it to the screen, i cant manage to get the info to display. Hopeing someone can help me figure out how or tell me what im doing wrong. Thanks
app.js
// listen for get request, aka transfers the info in mongo to client
app.get('/databases', function (req, res) {
console.log("-- recived GET request --");
db.open(function(err, db) {
// Use the admin database for the operation
var adminDb = db.admin();
// List all the available databases
adminDb.listDatabases(function(err, dbs) {
assert.equal(null, err);
assert.ok(dbs.databases.length > 0);
console.log(dbs);
res.json(dbs);
db.close();
});
});
});
controller.js
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
console.log("controller connected");
function refresh(){
// create route
$http.get('/databases').success(function(response) {
console.log("recived data requested");
$scope.databases = response;
});
}
// Call refresh to get req
refresh();
});// Controller
index.html
<body>
<div ng-app="myApp" ng-controller="customersCtrl">
<ul>
<li ng-repeat="contact in databases">
{{ contact }}
</li>
</ul>
<button type="button" onclick="hitMe()">Click Me!</button>
</div>
</body>
