News for hackers. Stuff that matters.
Re:Practical AngularJS Examples by bsaul on Sunday September 01, 2013 @05:41AM (#6309681)
Anyone got a post on how to structure big angular apps ?

i've been struggling a bit with menu bars : it seems to me that you can't prevent copy/pasting the menu bars on each of your screens if you want to keep meaningfull URLs (as the routing component only maps a url to a single controller).

Re:Practical AngularJS Examples by kops on Sunday September 01, 2013 @08:16AM (#6310064)
I used this http://stackoverflow.com/questions/12592472/how-to-highlight...

Works fine, as long as your URL scheme structured enough. Toss me your email, and I can give you the controller and the tmeplate code with link to the live site. I would have copy-pasted here but don't want to turn HN into stackoverflow.

Re:Practical AngularJS Examples by aram on Sunday September 01, 2013 @10:03AM (#6310382)
Do you mind creating a gist? It would help anyone reading this and you could just post a link.
Re:Practical AngularJS Examples by kops on Sunday September 01, 2013 @11:06AM (#6310644)
https://gist.github.com/kapilpandit/6404978

Disclaimer: I am no frontend/javascript developer. Just getting by.

Re:Practical AngularJS Examples by mbell on Sunday September 01, 2013 @10:29AM (#6310490)
Put your menu bar code in your 'master' template (wherever you're defining the location for your ng-view). Use a separate Nav controller for the menu bar.

It seems like your biggest issue is just data sharing, e.g. each page needs different menu items or something. Just create an Angular service that provides the backing data for the menu bar and exposes an API to other controllers to change things in the menu bar or get the value of a search field in the menu bar, etc. This type of thing is exactly what angular services are for.

Re:Practical AngularJS Examples by polyfractal on Sunday September 01, 2013 @10:34AM (#6310509)
Here is one of my angular projects:

https://github.com/polyfractal/elasticsearch-inquisitor

I'm not sure I would classify this as a "big" app, but it has four tabs and is slowly growing in functionality. The menu bar (and highlighting) is a very simple controller and service.

Obligatory disclaimer: I'm by no means an angular expert.

Re:Practical AngularJS Examples by diggan on Sunday September 01, 2013 @06:41AM (#6309775)
Use common sense. First step, having the files in one folder. Everything mixed up. You move into a structure of seperating services from directives, controllers from filters and so on. But the way most people seems to be doing it (the Angular way™) when it comes to the bigger applications is by splitting it up by functionality/modules. So you have a forum and therefore probably at least 3 different modules, "thread", "user" and "forum" or something similar. Just follow the MVC pattern with whatever filestructure that works with you and your team.

Copy/pasting the menu bars? For that, I would have a directive which controls the display of the menu and acting accordingly. Only when declaration is needed and it's reusable. I don't understand your point about meaningful urls though, they are as meaningful as you make them.

Re:Practical AngularJS Examples by bsaul on Sunday September 01, 2013 @08:17AM (#6310069)
well using a directive means you still have to put it everywhere ( in all your views). i'm more used to something like a master template with global menus and a content div. but for that you would need multiple ng-views or something similar, since my menu bars also need to be linked to the context.
Re:Practical AngularJS Examples by dchuk on Sunday September 01, 2013 @06:48PM (#6312506)
UI Router solves this problem pretty handily
Re:Practical AngularJS Examples by kops on Sunday September 01, 2013 @08:27AM (#6310098)
As for the structure, I tried Yeoman but quickly gave up due to learning curve and lack of time. I settled on a simple folder structure with minimal grunt file which uglifies and minifies my code. If minification/uglification wasn't a concern then I would have ditched grunt too. Not because I have issues with these cool tools, but purely because I just don't have time to understand them thoroughly. AngularJS itself helped fix my jQuery spaghetti wonderfully though.
Re:Practical AngularJS Examples by davej on Sunday September 01, 2013 @05:44AM (#6309689)
It's difficult to know for sure without seeing exactly what you're trying to do but perhaps a directive is what you want?

If you're looking for general app structure tips then the Angular generator for Yeoman is a good place to start.

Re:Practical AngularJS Examples by chrisrhoden on Sunday September 01, 2013 @08:27AM (#6310095)
You can listen for the $routeChangeSuccess event from outside of your ng-view. You can attach arbitrary key=> value pairs to your routes to annotate them in ways that are particular to your app.

Hope this helps, let me know if it is unclear.

Re:Practical AngularJS Examples by sararob on Sunday September 01, 2013 @11:07AM (#6310647)
If you want to add a backend to your Angular app, check out AngularFire. Here's the quickstart guide and tutorial: http://angularfire.com/quickstart.html
Re:Practical AngularJS Examples by lifeisstillgood on Sunday September 01, 2013 @11:57AM (#6310849)
The oreilly book is geared heavily towards best practise for just such apps.
Re:Practical AngularJS Examples by aram on Sunday September 01, 2013 @04:55AM (#6309566)
Sidenote: the code editor used to live-preview/edit how examples work is great; does anyone know of any similar OS projects?

Post author (Martin Angelov) said that he built it himself on Ace, however it doesn't seem to be OS.

Re:Practical AngularJS Examples by pearjuice on Sunday September 01, 2013 @09:08AM (#6310194)
Ace is open source: http://github.com/ajaxorg/ace
Re:Practical AngularJS Examples by aram on Sunday September 01, 2013 @10:02AM (#6310380)
I said that he built that editor on Ace. I'm using it and I know it's OS.
Re:Practical AngularJS Examples by Kiro on Sunday September 01, 2013 @10:50AM (#6310575)
I don't understand why a custom filter is needed in "4. Instant Search". I thought "<li ng-repeat="i in items | filter:searchString">" did the same thing.
Re:Practical AngularJS Examples by arbus on Sunday September 01, 2013 @11:29AM (#6310735)
I'm guessing that he wanted to show how to write your own modifiable filter with a simple example
Re:Practical AngularJS Examples by sheldor on Monday September 02, 2013 @02:12AM (#6313677)
I found these to be excellent resources when I started with angular almost a year ago.

http://www.yearofmoo.com/2012/08/use-angularjs-to-power-your...

http://www.yearofmoo.com/2012/10/more-angularjs-magic-to-sup...

Re:Practical AngularJS Examples by susi22 on Sunday September 01, 2013 @10:15AM (#6310431)
I really like this since the source code is well documented and explains everything right in the code.

Not like todomvc which is supposed to be for beginners yet have almost no comments...

https://github.com/tastejs/todomvc/blob/gh-pages/architectur...

Re:Practical AngularJS Examples by flylib on Sunday September 01, 2013 @02:22PM (#6311442)
your right, they should prolly focus more on commenting there stuff then making an example in every obscure framework possible
Re:Practical AngularJS Examples by elgamine on Sunday September 01, 2013 @06:32PM (#6312447)
In case someone missed this, http://www.egghead.io/ All angular basics pretty well explained
Re:Practical AngularJS Examples by dexterbt1 on Monday September 02, 2013 @01:38PM (#6316162)
I recently viewed a few of their videos and I find them too short, seemingly lacking. It might depend on the audience though. In my case, a little theory and architectural overview works better, and the official docs cover this well enough.
Re:Practical AngularJS Examples by jacques_chester on Monday September 02, 2013 @02:03AM (#6313646)
I disagree. I went through the whole series and then, when I sat down to write an angular app, found that I had no idea what I was doing.
Re:Practical AngularJS Examples by nawitus on Sunday September 01, 2013 @11:03AM (#6310625)
>ng-show will show an element if the value in the quotes is truthful,

What's the definition of truthful?

Re:Practical AngularJS Examples by Hovertruck on Sunday September 01, 2013 @11:06AM (#6310641)