Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Here is a practical answer, courtesy of user [Kirill Slatin][1] who posted the answer as a comment. Practical use example at the bottom of the answer.

If, like me, you need to use that response object as a scope variable, this should work:

$http.get('URL').success(function(data){

$scope.data = data;
$.fullCalender = $scope.data;
$scope.$apply()
});

$scope.$apply() is what will persist the response object so you can use that data.

-

Why would you need to do this?

I'd been trying to create an "edit" page for my recipes app. I needed to populate my form with the selected recipe's data. After making my GET request, and passing the response data to the $scope.form, I got nothing... $scope.$apply() and [Kirill Slatin][1] helped big time. Cheers mate!

Here's the example from my editRecipeController:

  $http.get('api/recipe/' + currentRecipeId).then(
    function (data) {
      $scope.recipe = data.data;
      $scope.form = $scope.recipe;
      $scope.$apply()
    }
);

Hope that helps! [1]: http://stackoverflow.com/users/4573999/kirill-slatinhttps://stackoverflow.com/users/4573999/kirill-slatin

Here is a practical answer, courtesy of user [Kirill Slatin][1] who posted the answer as a comment. Practical use example at the bottom of the answer.

If, like me, you need to use that response object as a scope variable, this should work:

$http.get('URL').success(function(data){

$scope.data = data;
$.fullCalender = $scope.data;
$scope.$apply()
});

$scope.$apply() is what will persist the response object so you can use that data.

-

Why would you need to do this?

I'd been trying to create an "edit" page for my recipes app. I needed to populate my form with the selected recipe's data. After making my GET request, and passing the response data to the $scope.form, I got nothing... $scope.$apply() and [Kirill Slatin][1] helped big time. Cheers mate!

Here's the example from my editRecipeController:

  $http.get('api/recipe/' + currentRecipeId).then(
    function (data) {
      $scope.recipe = data.data;
      $scope.form = $scope.recipe;
      $scope.$apply()
    }
);

Hope that helps! [1]: http://stackoverflow.com/users/4573999/kirill-slatin

Here is a practical answer, courtesy of user [Kirill Slatin][1] who posted the answer as a comment. Practical use example at the bottom of the answer.

If, like me, you need to use that response object as a scope variable, this should work:

$http.get('URL').success(function(data){

$scope.data = data;
$.fullCalender = $scope.data;
$scope.$apply()
});

$scope.$apply() is what will persist the response object so you can use that data.

-

Why would you need to do this?

I'd been trying to create an "edit" page for my recipes app. I needed to populate my form with the selected recipe's data. After making my GET request, and passing the response data to the $scope.form, I got nothing... $scope.$apply() and [Kirill Slatin][1] helped big time. Cheers mate!

Here's the example from my editRecipeController:

  $http.get('api/recipe/' + currentRecipeId).then(
    function (data) {
      $scope.recipe = data.data;
      $scope.form = $scope.recipe;
      $scope.$apply()
    }
);

Hope that helps! [1]: https://stackoverflow.com/users/4573999/kirill-slatin

Source Link
Bptstmlgt
  • 127
  • 2
  • 12

Here is a practical answer, courtesy of user [Kirill Slatin][1] who posted the answer as a comment. Practical use example at the bottom of the answer.

If, like me, you need to use that response object as a scope variable, this should work:

$http.get('URL').success(function(data){

$scope.data = data;
$.fullCalender = $scope.data;
$scope.$apply()
});

$scope.$apply() is what will persist the response object so you can use that data.

-

Why would you need to do this?

I'd been trying to create an "edit" page for my recipes app. I needed to populate my form with the selected recipe's data. After making my GET request, and passing the response data to the $scope.form, I got nothing... $scope.$apply() and [Kirill Slatin][1] helped big time. Cheers mate!

Here's the example from my editRecipeController:

  $http.get('api/recipe/' + currentRecipeId).then(
    function (data) {
      $scope.recipe = data.data;
      $scope.form = $scope.recipe;
      $scope.$apply()
    }
);

Hope that helps! [1]: http://stackoverflow.com/users/4573999/kirill-slatin