I thought the same thing. Im not sure about the $controllerScope idea,
seems complex, and duplicates a lot of functionality Basically making the
container scope useless - or going back to the days where the controller IS
the scope.
I'd suggest that we really just need a reference to the controller that
doesnt rely on the alias, as that has coupling issues as you stated.
having a $ctrl variable created on the $scope, which always references the
controller would mean you can do:
$scope.$watch('$crtl.MyVar', function() {
console.log('x');
})
It seems a handy way to access the controller in general id think
http://plnkr.co/edit/KG80zvTbG8ZQZfy5PsEx?p=preview
On 20 February 2014 13:16, Guillaume Lecomte <[email protected]> wrote:
> Sorry to bring that back but am I the only one who see a design problem
> here?
> We define an alias in the view/template ( MyCtrl as controller ), if we
> want to watch a variable in the (controller) scope from the controller, we
> need to know the alias we defined in the template
> ($scope.$watch('controller.varname', ...),
> it's not DRY, it generates coupling and prevent reusing several times the
> same controller (nested).
>
> I'm suggesting a $controllerScope injectable (a $scope 'scoped' on the
> controller) to solve that, does anyone else want something like that?
>
> Le vendredi 14 juin 2013 21:19:12 UTC+2, Guillaume Lecomte a écrit :
>
>> Doesn't that feature need a way to inject a controllerScope in the
>> controller (a scope where this is the controller) to be able to watch
>> members agnosticly of the alias defined in the view to be complete? Or
>> provdide a way to mixin that scope in the controller?
>
> --
> 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/groups/opt_out.
>
--
Tony Polinelli
--
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/groups/opt_out.