That's more or less what I do. I have rather fat models and thin
controllers. Usually the controller gets a model based on route - /people/1
or whatever.

I also attach convenience functions on the controller sometimes, when
they're route-specific. Something like profile.follow() would be on the
model, but the "save and close" button on people/1/edit is defined in my
controller as profile.save(); $state.go('^') sort of thing. It's kind of a
"whatever feels right".

It took me longer to build my behaviors out than if I were just attaching
things to the controller (more files, more generic programming needed), but
this way I can reuse all the profile model code in /people/1 and when
displaying a user avatar in /communities/1 or as an author of /documents/1.
So in my experience, worth it for medium-large applications, maybe not so
useful for smaller single-shot applications.

e

On Mon, Sep 15, 2014 at 7:32 AM, Ben Rethmeier <[email protected]> wrote:

> I'm getting started with Angular coming from an MVVM (XAML)
> world\perspective. I started by seeing my controller as my ViewModel and I
> just put everything on its scope and had thought that services were
> primarily for like server call services (ajax call to get some data or
> something). Now I'm starting to feel like I should make all code into a
> service and just glue them together in a controller and have the controller
> have really no code, just pulling things from services onto the scope. Does
> that sound reasonable? I know you can use the tool anyway you like, so I
> guess I'm asking what do people usually put in their controllers and is
> there good reason not to put it in a service other than preference or ease?
>
> Any thoughts, opinions, or feedback is appreciated.
>
> --
> 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.
>

-- 
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