Both options look good to me. I usually avoid to use direct method calls in 
my Angular expressions though as change listeners basically have to 
reevaluate that method call way too often to make sure the returned value 
has not changed. If you use a $scope variable instead, then that issue is 
gone plus you would get the additional benefit of two-way data binding.

What I would do: 
- Init a $scope.credits variable with your service call when your 
controller is initialized
- Use the $scope.credits variable in HTML instead of method calls to your 
service

On Friday, June 12, 2015 at 10:30:47 AM UTC-7, César Barone wrote:
>
> Hi,
>
> I am implementing a AccountService that is storages an account object that 
> contains some informations about user account and used in some parts of my 
> application . I asking for my self what is the better way to access account 
> object properties. I created two plukers that demonstrates two differente 
> approaches and i need i help of the pros an cons of each approach.
>
> In this plunker i am binding account properties direct from view
> http://plnkr.co/edit/7Chq0sKpnCJVfk7SLj5w?p=preview
>
> In this plunker, i am created an API to access account properties
>
> http://plnkr.co/edit/26e8mHNWfrrxqFltbyPa?p=preview
>
> Any one suggests another approach?
>
>  Thanks
>

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