Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NODE and CMS with angularjs: how do they cooperate

I'm thinking about making something with the MEAN stack. I need a way to edit the content of the site, like e.g. Wordpress offers (basically a CMS).

The confusing bit is how the CMS and Angular would work together. I've looked at a CMS named Keystone, and there you have to set up some routing etc. in Node. Won't this crash with the routing you set up in Angluar?

In other CMSs I've used, the creation of the views happens on the server side. In Angular, as far as I understand, you crate a HTML template, which you can populate with data in an angular controller. This also seems like something that could crash between CMSs and Angular. Is this the case?

Is there any other quirks or similar about Angular and content managment systems I should know about, or is it usually not much problems integrating the two?

like image 382
ptf Avatar asked May 05 '14 14:05

ptf


3 Answers

meanjs.org has a pretty good approach to this. Install meanjs. It comes with a sigin/signup and even allows you to create articles from the vanilla install.

Put simply, when you are creating a web app with the MEAN stack, think of AngularJS as "THE" app, and node.js as the api. If you approach building your web app as a javascript application (AngularJS), that happens to get its data from an server api (node.js), then you will begin to understand how to properly use the MEAN stack.

First: Angular will have the routes defined in the $routeProvider. Build the routing urls in AngularJS first. They are "THE" routes for your web app. A good way to look at it is to build the AngularJS portion with the ability to change your api server, even to another language (PHP, python, go, etc) if necessary.

Second: Build your AngularJS to communicate to the api with $resource. Essentially a $resource is an easy way to call out to an api using restful routing. This "restful routing" is now the routing that needs to be "mimicked/copied" into the routing for the node.js routes.

Often the AngularJS routes (the url) will match the $resource routing that matches the node.js routing.

Again, take a look at meanjs.org and you will have a better understanding on how to properly organize what "seems like" (and actually are) two separate apps.

like image 87
Jon Avatar answered Oct 19 '22 03:10

Jon


Basically, you need three sets of routes (or two if you are doing it on the cheap).

Start out with a set of routes on the server that return regular webpages. Forget about JavaScript. Do not involve Angular at this stage.

Second, add another set of routes on the server which return data in a rawer form (such as JSON). This would typically be a RESTful API.

Third, add Angular to the client. When the view needs to be updated, update the URL in the browser and use Ajax to hit the RESTful API to get the data needed to populate it. (You want the URL you set the address bar to to match the URL of the page from the first set of routes that you are duplicating with JS and the data from the RESTful route).

If you are doing it on the cheap, like Gawker did, then you would skip the first set of routes and go direct to the JS+REST approach.

like image 24
Quentin Avatar answered Oct 19 '22 02:10

Quentin


I think you need CMS on MEAN stack development environment. there are some cms on mean stack you can try.

  1. PancilBlue
  2. Calipso

try this.

like image 1
roconmachine Avatar answered Oct 19 '22 03:10

roconmachine