从服务中的控制器获取值

时间:2015-11-20 08:40:13

标签: javascript php angularjs service controller

我想获取在服务器中获取的值,该值在控制器中传递并传递给php页面。从控制器推送$scope.Album值。现在我得到它并在var get_save_album中加载服务中的本地存储。我想在没有本地存储的情况下直接获取它并将其提取到php页面。

controller.js:

$scope.savealbum = function () {
  $scope.getAlbum = AlbumServices.get_album();
  $scope.Album = {
    .... value....
  };
  if ($scope.getAlbum === null) {
    $scope.initalPush.push($scope.Album);
    AlbumServices.save_album($scope.initalPush);
  } else {
    $scope.getAlbum.push($scope.Album);
    AlbumServices.save_album($scope.getAlbum);
  }
  alert('Album Added Successfully');
  $location.path('/album_list');
};

JavaScript的:

get_album: function () {
  var get_save_album = JSON.parse(localStorage.getItem('album'));
  $http.post('js/data/album.php',get_save_album)
    .success(function (data, status, headers, config)
    {
      console.log(status + ' - ' + data);                 
    })
    .error(function (data, status, headers, config)
    {                   
      console.log('error');
    });

  return get_save_album;
}

0 个答案:

没有答案
相关问题