I agree with Antonio.  You are going to shoot yourself in the foot putting 
everything on $rootScope even though it will seem easier to start. 
 Services are the way to go, period.  It took me awhile to realize what 
Antonio and others are saying: your model should be in your services not on 
the $scope in the controller.  It will make sense in the long run.  But if 
you must learn the hard way, try it on $rootScope first.  Though you will 
probably get it to work, once your application is big enough, it will be 
much more problematic to manage.

On Thursday, March 27, 2014 12:50:38 AM UTC-6, Antonio Fernández Porrúa 
wrote:
>
> 1. The values are not copied, just referenced.
>
> 2. You should not use your scope as your model, and you do not need to.
> Put in the scope only the things needed in the view, neither more nor less.
> This way there are less values to check.
>
> 3. Your service could be just a javascript empty object, where you store 
> anything you want.
>
> angular.module(foo).service('bar',function(){ return this; });
>
> Then in your controler
>
> If(bar.baz === undefined){
> bar.baz = $scope.baz
> }
> $scope.baz = bar.baz
>
> If baz is an array or an object this will work fine, so you can use an 
> object to store strings and numbers
>
>

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