Integrating AngularJS with an ExpressJS project
Now that we have most of our server-side code working, we'll start working on our AngularJS code.
Let's download the angular-seed
project as a ZIP download from https://github.com/areai51/angular-seed and extract the contents of the ZIP file.
Now, we will only take the content of the app
folder along with the package.json
and bower.json
files and place it within the public
folder of angcms
.
In the terminal, navigate to the angcms/public
folder and run the following two commands:
npm install bower install
Note that we do not run npm start
from within the public
folder, as we will be using the Express server that runs at port 3000.
Your folder structure should look something like the following:
The next step is to define the routes in our ExpressJS app such that all routes are managed by AngularJS, except for those that start with a/api/
.
For this, we will add the following catch-all route at the end of the angcms/routes/index.js
file as follows:
router...