[LRUG] [JOBS] Help with AngularJS + Rails

Stephen Masters stephen.masters at me.com
Wed Feb 19 07:33:58 PST 2014


Agustin,

I just wanted to say well done on including services in your example as an equivalent to Rails models. I find it a much better way of thinking of them compared to pretty much every other explanation of AngularJS services out there.

I have spent quite a bit of time over the past week or so going through online AngularJS materials, and pretty much everything (including the main tutorial) seems to treat services as an afterthought. The Green & Seshadri book from O’Reilly is a particularly bad example of this. I would have experienced far less pain if those materials had shown the use of services early on.

I’m guessing that it’s easier in tiny demo examples to just dump everything inside a controller, as it involves less code, but an application doesn’t need to be big at all (mine is currently barely 200 lines of JavaScript) before it will benefit from refactoring large chunks out into one or more services. The trouble is that because there are so many examples of using controllers to store models and view state in $scope, noobs such as myself assume that it’s the "AngularJS Way” of doing things. And looking at StackOverflow questions and apps linked from angularjs.org, that can to lead to some unfortunate design decisions, such as storing variables in $rootScope in order to make them available across multiple controllers.

So thank you again for attempting to demonstrate a well structured AngularJS application, rather than showing how awesome interactivity can be implemented on a web page with 10 lines of code or less. :)

Cheers,

Steve



On 25 Jan 2014, at 14:23, Agustin Viñao <agustinvinao at gmail.com> wrote:

> A new post: http://blog.agustinvinao.com/post/74489979042/angularjs-validations-with-rails-model-validations
> 
> AngularJS form validations using Rails model's defined validations, with a code example how we can use those validations in rails to the AngularJS without write all again in our form.
> 
> Code example: https://github.com/agustinvinao/blog-examples/tree/master/form-validation
> 
> -- 
> --
> Agustin Viñao
> Paradox: Life is a mystery. Don't waste time trying to figure it out. / Humor: Keep a sense of humor, especially about yourself. It is a strength beyond all measure. / Change: Know that nothing stays the same.
> 
> Web Developer - Ruby - Javascript
> 
> m: agustinvinao at gmail.com
> t: http://twitter.com/agustinvinao
> w: http://www.agustinvinao.com
> g: http://github.com/agustinvinao
> l: http://ar.linkedin.com/in/agustinvinao
> f: http://www.facebook.com/saltoaciegas
> g+: http://profiles.google.com/agustinvinao
> 
> 
> On Wed, Jan 22, 2014 at 6:17 AM, Paul Jackson <pjackson at mbs-projects.com> wrote:
> Great post Agustin. As someone getting up to speed with Angular/Rails, I found this simple, practical example really useful.
> 
> Paul
> 
> 
> 
> On 21 Jan 2014, at 19:34, Agustin Viñao <agustinvinao at gmail.com> wrote:
> 
>> After I saw all this comments I wrote a post in my blog explaining how to move something in your Rails app to an AngularJS app.
>> 
>> The example I'm using for this time only consumes and renders data, you can see this example working here http://opendatamdq.com.ar/providers/singlepage.
>> 
>> http://blog.agustinvinao.com/post/74084133569/rails-angularjs-a-generic-approach
>> 
>> This post covers:
>> Create the AngularJS app
>> Prepare your rails app
>> Define all routes your AngularJS is going to use.
>> Define Models/Controllers in your AngularJS app.
>> Define your AngularJS view and render data.
>> My example uses many other things like filters, directives, etc but for now I've started with the most generic things you need to understand to use AngularJS. In this case my approach is try to avoid massive changes in my rails code and do ir all I can to divide my Rails app and my AngularJS app.
>> 
>> Thanks and sorry if my english is not good enough, is not my natural language. 
>> 
>> If anyone have any questions, please let me know.
>> 
>> -- 
>> --
>> Agustin Viñao
>> Paradox: Life is a mystery. Don't waste time trying to figure it out. / Humor: Keep a sense of humor, especially about yourself. It is a strength beyond all measure. / Change: Know that nothing stays the same.
>> 
>> Web Developer - Ruby - Javascript
>> 
>> m: agustinvinao at gmail.com
>> t: http://twitter.com/agustinvinao
>> w: http://www.agustinvinao.com
>> g: http://github.com/agustinvinao
>> l: http://ar.linkedin.com/in/agustinvinao
>> f: http://www.facebook.com/saltoaciegas
>> g+: http://profiles.google.com/agustinvinao
>> 
>> 
>> On Mon, Jan 20, 2014 at 11:10 PM, Don Werve <don at werve.net> wrote:
>> On Jan 20, 2014, at 18:55 , David Burrows <david at designsuperbuild.com> wrote:
>> 
>> > Jasim, just catching up on this thread, thanks for the extensive notes, massively useful - you should put this up somewhere (blog, company site, whatever) people ask me about Rails/Angular all the time and would love to be able to point them at this.
>> 
>> I second that, and as an added bonus will tweet the hell out of it to my massive following of ~ 300 people. It's an excellent write-up.
>> 
>> There's definitely a need for more people that work with Angular to post best practices and real-world production pitfalls and solutions.
>> _______________________________________________
>> Chat mailing list
>> Chat at lists.lrug.org
>> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>> 
>> _______________________________________________
>> Chat mailing list
>> Chat at lists.lrug.org
>> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
> 
> 
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20140219/1eaaa9d7/attachment-0003.html>


More information about the Chat mailing list