Using AngularJS as Front-End to Sails.js
Single Page Applications
Single page applications (SPA) are better built with front-end frameworks that have more general capabilities going beyond templates. Being familiar with AngularJS with its enhanced HTML and two-way data binding, I decided to use AngularJS as the front-end to a server-side Sails.js.
AngularJS with Sails.js
An AngularJS app was constructed by deriving from angular-seed. The contents of the
angular-seed/app folder was placed in the
The Sails.js server listens on port 1337 (by default, but this could be configured), so the AngularJS app url was:
and voila, we have an AngularJS front-end to a Sails.js server.
To make API calls from the front-end to the server we use standard AngularJS
$resource. Because the front-end and server are hosted on the same domain and port there are no cross-domain issues. These calls go to the Sails.js controllers.