Jimmy Bellmon Jimmy Bellmon - 1 month ago 13
Javascript Question

add angular 2 to existing express structure

I created an express structure using

express-generator
giving the standard structure:

bin
bld
node_modules
public routes
views
app.js
package.json


I would like to add to the views and routes directory as such:

views
->angular2
->->index
->->about
->->services
->->contact
->->sign up
->->sign in


using routes, index folder (index.js) and about folder (about.js) ...and so on...:

router.get('/', function(req, res, next) {
res.render('angular2/index/index.html');
});

router.get('/about', function(req, res, next) {
res.render('angular2/about/index.html');
});


I'm thinking each folder to render the angular 2 index.html. There are not too many examples on how to add angular 2 on an existing express structure. I know how to create, use, and program in an angular 2 structure. It's the setup that gets me. I'm a programmer a coder, and installing these various structures are new to me. I have tried express angular generators but they are are too heavy with a bunch of files and folders I don't need. I just need a simple structure for the index.html and the component.ts files to code in. How can I set this up without changing all the code and structures I already have in express? Also what is the simplest 'best practice' structure I can use to just place angular inside the desired folders?

Thanks all!




My aim is to be able to share information between the Nodejs system apps and the Angular 2 client apps. I know that I can do this by creating APIs between the two servers. My question is, is this the best practice or is there another method to use to accomplish this more efficiently?

Answer

Meteor.js is a Godsend. Trying to create a Fullstack just so I can start programming for a while now, but I could never create the best system I need for everything. 2hrs after installing Meteor.js and I'm ready. I now have about 2 weeks of production creating my application. And still get to use Angular 2! Like I mentioned above, I'm a programmer a coder, with PHP and C# experience, and installing these various structures are new to me. I'm used to just start writing programs. But I'm glad I got the experience of trying to create my own.