AngularJS: Load JSON data with bindings in place, doesn't keep any bindings

54 Views Asked by At

Say I attempt to store an object as plain text that features many model - view bindings with a rather simple function.

$http.post("storeJSON.php", {
    data: {
        data: JSON.stringify($scope.data),
        title: $scope.title
    }
})

$scope.data contains all the data my AngularJS app needs to render a particular view.

I used JSON.stringify to keep $$HashKey in an attempt to keep model - view bindings for later use. Aka a Save feature. I pick up back this object in another function.

$http.post("getJSON.php", {
        data: {
            path: path
        }
    }).then(res => {
        $scope.data = angular.fromJson(JSON.parse(res.data));
        console.log($scope.data);
    });

Expected result? Reload the same view later by fetching this same $scope.data variable intact. It displays all values, except it's missing the bindings from when it was first created. $$HashKeys are still there but do nothing by themselves.

0

There are 0 best solutions below