Ask HN: AngularJS frontend – Rails API backend service. Is this approach sane?
I've started reading up on frontend javascript frameworks, and I've settled on AngularJS because of it's large adoption rate and amount of work available for each. AngularJS is clearly ahead of the pack in that area.
I've been reworking my website entire using plain .html files with Angular requesting data from my Rails API. Essentially, my webapps will actually be two completely decoupled application. 1 being the Rails API hosted on some server, and the other plain old html files being served from a varnish endpoint.
Is this approach proven? Am I ignoring potential pitfalls as a newbie to clientside javascript frameworks? I see the huge benefit of being able to quickly make an Android or iOS app using my same API.
(
3 comments
| 6 points
| on HN
)
But you didn't write very much about your application's requirements, so it's not clear if this architecture is the best fit.
In general I would recommend that for a website (content-based), it's better to stick with generating HTML on the server. For applications (heavy user interaction) I would recommend going for client/server, and generating the UI dynamically on the client.
My reasoning is that for a website, generating the pages on the server leads to a simpler architecture, faster response times and easier SEO. And for applications, keeping state and UI client-side leads to increased responsiveness and easier scalability (since there is less state server-side and the requests are service-based).
2. Make a decision about routes quickly - either use the angularJS routes or Rails, but I would shy away from both. Personally, I found AngularJS routes annoying, specifically when it comes to SEO optimization.
3. If working with bootstrap, use http://mgcrea.github.io/angular-strap/ I highly recommend it