Angular and MongoDB

23 views
Skip to first unread message

Kevin Burton

unread,
Mar 1, 2016, 11:19:18 AM3/1/16
to mongodb-user
This is definitely a newbie question.

I have seen countless tutorials and course on using Angular with MongoDB using Node.js. But I am not sure how to set it up when not using node.js. I would like to build an Angular service that queries a MongoDB server but it doesn't seem possible. The first hurdle that I run up against is that 'require' doesn't seem to be defined. For example I have (excuse the TypeScript):

 export class FormService implements IFormService { static $inject = ['$q'];
 constructor
(private $q: ng.IQService) {
 
this.mongo = require('mongodb')
 
}


How do I gain access to the node.js drivers?

Thank you.

Kevin

Stephen Steneker

unread,
Mar 4, 2016, 9:13:03 PM3/4/16
to mongodb-user
Hi Kevin,

Angular is a frontend application framework, so typically is paired with a server-side language on the backend (eg. Node.js) for application logic & data processing. Generally you do not want to have your database servers open to the world, so your Angular application should be connecting to a secure API endpoint. You can develop a custom API using Node.js or your preferred server-side language, or consider using a RESTful API if your requirements are more generic (for examples, see: REST interfaces).

For a more detailed introduction to working with MongoDB and Angular, you might be interested in the free online course "Introduction to MongoDB using the MEAN Stack" from MongoDB University.

Regards,
Stephen
Reply all
Reply to author
Forward
0 new messages