Hi Łukasz,


>    - does either of the solutions hides some bugs or flaws?
>
> No, it’s basically exactly the same thing. However, I think the second 
approach might confuse you. let me explain.
you decide to do some assigning in your controller, like setting the 
selectedUserIs so you do in your controller:
selectedUserId = fetchAUser();. This will not update 
$scope.model.selectUserId. You have to remember that
JavaScript primitives 
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals>,
 
are never passed by reference. 


>    - is the overhead of watching the scope is higher/lower in any case 
>    (performance implications)?
>
> No. As I said, it is exactly the same thing. there is no difference in the 
$scope. All that you have done is
put some extra visual clues in your code. with exception of the primitives 
as mentioned above. those will
consume some extra memory (the extra reference to the array will do to, but 
this is such a small amount,
you can safely ignore that)


>    - is there any recommended way of doing this?
>
> Your first way is the recommend way if you still want to use $scope. The 
current recommend way is to
use the controllerAs syntax, in where the $scope inheritance is mostly 
mitigated.
I created a sample plunk here <http://goo.gl/rEqT53>, that I created for 
someone that needed localized events. There are a
couple of controllers in there that follow the new recommend way.
When you have any questions left, don’t’ hesitate to ask!

Regards
Sander
​

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