Angular.js: What's the best way to do this?

Wiseguy2001

2[H]4U
Joined
Nov 28, 2001
Messages
3,470
I'm currently working on a project, it handles editing lots of different types of items. It has some lists of items on the left-hand pane (currently 4 different lists) and tabs in the centre. Essentially an IDE.

Editing some of these items needs to update the list (renaming, creating) or deleting an item (which needs to update it's list and close the tab). Updating itself in the list would be preferable, but reloading the list from the server isn't too painful.

I don't want the scope to get too massive (currently each tab is in a isolated scope). Would broadcasts be the best way to handle this? I'm looking for a fairly DRY technique without too much coupling, want to keep the types and tabs separate.
 
I'm pretty new to angular so this is just my feeling on it, I'm not a guru or expert by any means.

In this case I would think about using a shared data service. You could combine the service with some eventing as needed. Make sure to be careful about using $broadcast vs $emit.

I'd be interested in what you come up with as I'm new to all this and learning a lot along the way.
 
As the communication is always up stream, $scope.$emit is working nicely.

Just using two methods/ channels (update and drop), which are implemented in a base controller.

When you get your head thinking 'the Angular way' it's a really nice framework.
 
Back
Top