I'm not an expert, but everything I've read from experts has said to use a 
service in this situation.  

Check out examples from here 
<http://www.dancancro.com/comparison-of-angularjs-application-starters/> 
that have YES next to "demos full-stack CRUD".

I'm trying to nail down a complete list of the types of code that should go 
into a controller because most say you should have no more code here than 
absolutely necessary and everything else should go into services because 
services are uncoupled from views and reusable and hold state between 
routes.  You could even just set a whole service as a property of the 
controller and call its methods directly from the view code, but that makes 
it unclear which methods the view is able to use, and some say the job of 
the controller is to limit and clarify what the view code is allowed to do.

Anyway, check that link for just about anything you could want to know 
about the variety of approaches.

On Sunday, October 19, 2014 7:56:05 AM UTC-4, Evgeny Nepomnyashchiy wrote:
>
> Hello guys,
>
> I have an architectural question about Angular.
> I'm creating small application, which manipulates items (let's say 
> abstract items), user can see a list, add, edit, and delete them.
> There are two views: "list" and "add", I switch between them with ng-view 
> directive. I have the following controllers:
> MainController, ListController (for "list" view), AddController (for "add" 
> view). In "add" view user see another list of "last added" items.
> I put "list" logic (load items from server) to ListController. I put "add" 
> logic to AddController.
>
> But in both views user can edit and delete items, in case of "add" view I 
> can add and delete items in "last added" list (which reflects in main 
> "list" too).
> Where do I need to put edit and remove logic part? In MainController 
> because it is common? Or do I need to use service for
> manipulate lists? I don't know how to create good architecture for these 
> parts.
>
> Thank you.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to