Drupal-Angular Hybrid Apps
- Model (application data) is fetched from server-side restful services and it is transferred over JSON via AJAX requests to and fro. We can improve the user experience by persisting the application data in the browser in local storage.
- View (Single Page) is the page with static HTML partials (templates) transferred over AJAX which doesn’t actually contain any data and is required to load only once (therefore highly cacheable)
This approach results into a simpler backend as all we have to write is a function that fetches data and returns data and has nothing to do with presentation layer, while front end deals with static HTML partials (templates) only. Overall its gives better user experience, better performance and faster development.
I would posit that Drupal is best CMS to use when web applications does have lot of content but AngularJS is best front-end used for web applications while REST is the best way to choose the backend services. Thus mixing Drupal with AngularJS is a smart choice. You can use the following approach to build your Drupal-Angular hybrid apps:
- Develop the Angular application independent of Drupal
- Write a custom module to integrate Drupal with Angular application (SPA) as if, it was just a block. See restng.org for an example
- We can Drupal's REST services with restws module (there are many other REST services but we recommend RESTWS as its bit simpler).
- Add other custom REST services on platform of your choice, as well as third-party REST services.
- Use JSON Web Token (JWT) for security integration.
- Optionally, allow Local Storage for browser-side persistence for better user experience.
SpinSpire has a great team of developers who have worked on hybrid web applications (Drupal+AngularJS) extensively. Please feel free to drop us a line for your application requirements.
Also, check out the video of my presentation at DrupalCamp Atlanta 2014 on the same topic - http://drupalcampatlanta.com/2014-drupalcamp-atlanta/sessions/developing-drupalangularjs-hybrid-apps