I want to watch over one of $rootScope variable.
It works and update bar when I explicitly register a watcher:
$rootScope.$watch('foo', function(newVal) {
$scope.bar = newVal;
});
But it does not update when I just assign bar to $rootScope's foo. Shouldn't it implicitly assign a watcher for this expression?
$scope.bar = $rootScope.foo;
By the way, foo is initially an empty object, and it is updated to {'test': 'something'} later.
UPDATE
It is now clear that this expression won't assign a watcher and update itself. So, is there any way to update bar without a watch function in controller?
Are promises available for this purpose? I think Restangular can do it like this:
$scope.list = Restangular.all('accounts').getList().$object;