Json AngularJs+;查看/更新数据的最佳实践-更新后再次在模型中重新加载数据

Json AngularJs+;查看/更新数据的最佳实践-更新后再次在模型中重新加载数据,json,angularjs,Json,Angularjs,在我的angularjs应用程序中,我对标准的实现方式有点困惑。请看一下我的代码结构,并提出一些建议,使其更有效 var app = angular.module("UserApp", []); app.controller('UsersListCtrl', function ($scope, $http) { $http.get('/ShowAllUsersList.json').success(function(data) { $scope.users = data

在我的angularjs应用程序中,我对标准的实现方式有点困惑。请看一下我的代码结构,并提出一些建议,使其更有效

var app = angular.module("UserApp", []);

  app.controller('UsersListCtrl', function ($scope, $http) {
    $http.get('/ShowAllUsersList.json').success(function(data) {
      $scope.users = data;
    });
  });

  $http.get('/LoggedInUserInfo.json').
    success(function(data, status, headers, config) {
      $scope.logged_in_user = data;
    }).
    error(function(data, status, headers, config) {
      // log error
    });
  }    

  app.controller("LoggedInUserInfoCtrl", ['$scope', '$http', function($scope, $http) {
    $scope.updatePersonalInfo = function() {
      $scope.user_personal_info = {
        username: $scope.logged_in_user.username,
        primary_email: $scope.logged_in_user.primary_email,

        first_name: $('#first_name').val(),
        last_name: $('#last_name').val(),
        secondary_email: $('#secondary_email').val(),
      };

      $http.put('/UpdatePersonalInfo', $scope.user_personal_info).
        success(function(data, status, headers, config) {
           alert('Data updated successfully.');
        }).
        error(function(data, status, headers, config) {
          alert('error');
        });
    };

  }]);
现在,我无法在不重新加载页面的情况下完全重新加载范围内的数据。我试图把加载功能,但它无法工作。请提出一些建议


提前感谢

您需要提供一项服务,以跨控制器和作用域持久化数据

请阅读以下文件:


还有一段视频:

谢谢回复。我正在寻找数据的更新,然后通过减少代码行来使用scope重新加载数据。也得到了使用函数共享数据的想法。