Work with the update of $scope variables


Dear ionic-forum,

I run into strange issues with the update of $scope variables.

  1. In a controller I have a $scope.i18 = {...} - its an object with a couple of keys and string values. When I am updating this Object in a function like $scope.updateLang = function(lang){ $scope.i18 = Translation.updatei18(lang); };
    (while Translation is a factory and the function updatei18 it just returns a new object) - in the view the variables don’t get updated automatically as they should. I now have to run threw each variable and update it like this:

    $scope.updateLang = function(lang){
    $.each(Translation.updatei18(lang), function(i,e){
    $scope.i18[i] = e;
    And this is ugly to my mind.
    So my first question is: is there a way to update the whole $scope object at once?

2 - I have several views and each has got its controller. Each controller loads the i18 object at the beginning like this:
.controller('Contr1',function($scope, Translation){ $scope.i18 = Translation.reti18(); }) (while the function reti18 it just returns an object with keys and string values like above)
So every controller basically gets the same i18 object.
Here is my scenario:

  • I got to view 1 and run the updateLang function from above. Then the view-variables get updated
  • then I go to view 2 and see that the view-variables are also updated here (which is good).
  • Then, staying in that view 2 I run the same function updateLang and nothing happens - no variables get updated - nither in view 2 nor in view 2. No matter what I do and how often I update the $scope variables - the view doesn’t change.

Please - could you help me understand, what are my errors?
If you need more code to understand it, tell me, I will provide

Thanks a lot!