I have two tables in my page, and upon clicking on a row on the first table, i wanted to call an ajax request to update the second table.
I'm trying to do this with two controllers, each of them with an ng-repeat filling the rows with values. I've burned out every neuron i could afford and I'm still stumped.
This is my code
app.controller("TermsCtrl", function($scope, $http) {
    $http.get('json.php').then(function(res) {
        $scope.wordfreq = res.data;
        $scope.decodeURIComponent = decodeURIComponent;
        $scope.unescape = unescape;
    });
    $scope.go = function(id) { // This makes the rows clickable and calls the next results
        return $http.get('json2.php?word=' + id).then(function(result) {
            secondtable = result.data;
            console.log(secondtable); // I see the objects!
            return secondtable;
        });
    };
});
app.controller("TermsCtrl2", function($scope, secondtable) {
    $scope.secondfeq = secondtable;
    console.log(scope.secondfeq); // No dice
});
Any ideas how to get the secondtable results from the click into the TermsCtrl2 controller?
cheers
secondtablehere? it isn't the name of a service, and it isn't a property on$scope, were you trying to declare it as a global variable on window?secondtablewas supposed to be the data i wanted to take over the the second controllersecondtableafter the success of the$http.get, which is in turn returning that to be stored in$scope.go. Technically, inside the$scopeof"TermsCtrl"you have agoproperty that has your data, but it wouldn't be visible on the$scopeof"TermsCtrl2", and in fact, your script probably throws an error trying to resolvesecondtableas an input parameter for your controller. I would say that refactoring the code the way @CT14.IT suggested is the right way to go....