title: Angularjs must refresh page to see changes
body: <p>What I have is simple CRUD operation. Items are listed on page, when user clicks button add, modal pops up, user enters data, and data is saved and should automatically (without refresh)be added to the list on page.</p>
  
  <p>Service:</p>
  
  <pre><code>getAllIncluding: function(controllerAction, including) {
              var query = breeze.EntityQuery.from(controllerAction).expand(including);
              return manager.executeQuery(query).fail(getFailed);
          }, 
  
  addExerciseAndCategories: function(data, initialValues) {
              var addedExercise = manager.createEntity("Exercise", initialValues);
              _.forEach(data, function(item) {
                  manager.createEntity("ExerciseAndCategory", { ExerciseId: addedExercise._backingStore.ExerciseId, CategoryId: item.CategoryId });
              });
              saveChanges().fail(addFailed);
  
              function addFailed() {
                  removeItem(items, item);
              }
          },
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code> $scope.getAllExercisesAndCategories = function() {
          adminCrudService.getAllIncluding("ExercisesAndCategories", "Exercise,ExerciseCategory")
              .then(querySucceeded)
              .fail(queryFailed);
  
      };
  
       function querySucceeded(data) {
  
              $scope.queryItems = adminCrudService.querySucceeded(data);
  
              var exerciseIds = _($scope.queryItems).pluck('ExerciseId').uniq().valueOf();
              $scope.exerciseAndCategories = [];
              var createItem = function (id, exercise) {
                  return {
                      ExerciseId: id,
                      Exercise : exercise,
                      ExerciseCategories: []
                  };
              };
  
              // cycle through ids
              _.forEach(exerciseIds, function (id) {
                  // get all the queryItems that match
                  var temp = _.where($scope.queryItems, {
                      'ExerciseId': id
                  });
                  // go to the next if nothing was found.
                  if (!temp.length) return;
                  // create a new (clean) item
                  var newItem = createItem(temp[0].ExerciseId, temp[0].Exercise);
                  // loop through the queryItems that matched
                  _.forEach(temp, function (i) {
                      // if the category has not been added , add it.
                      if (_.indexOf(newItem.ExerciseCategories, i.ExerciseCategory) &lt; 0) {
                          newItem.ExerciseCategories.push(i.ExerciseCategory);
                      }
                  });
                  // Add the item to the collection
                  $scope.items.push(newItem);
              });
  
  
              $scope.$apply();
  
          }
  </code></pre>
  
  <p>Here is how I add new data from controller:</p>
  
  <pre><code> adminCrudService.addExerciseAndCategories($scope.selectedCategories, { Name: $scope.NewName, Description: $scope.NewDesc });
  </code></pre>
  
  <p>So my question is, why  list isn't updated in real time (when I hit save I must refresh page).</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here is my querySuceeded</p>
  
  <pre><code>querySucceeded: function (data) {
              items = [];
              data.results.forEach(function(item) {
                  items.push(item);
              });
              return items;
  
  
          }
  </code></pre>
  
  <p><strong>EDIT 2</strong></p>
  
  <p><strong>I believe I've narrowed my problem !</strong></p>
  
  <p>So <a href="https://stackoverflow.com/users/1200803/pw-kad">PW Kad</a> lost two hours with me trying to help me to fix this thing (ad I thank him very very very much for that), but unfortunately with no success. We mostly tried to fix my service, so when I returned to my PC, I've again tried to fix it. I believe my service is fine. (I've made some changes as Kad suggested in his answer).
  I believe problem is in controller, I've logged $scope.items, and when I add new item they don't change, after that I've logged $scope.queryItems, and I've noticed that they change after adding new item (without refresh ofc.). So probably problem will be solved by somehow $watching  $scope.queryItems after loading initial data, but at the moment I'm not quite sure how to do this.</p>