here's my issue: I want to run the code of controllerB into controllerA. The issue is that while the variables are returned to the controllerA, the values from requests are never returned. Here's a plunker to show the issue: http://plnkr.co/edit/GqC9BOKTi8HxQLf2a2yd?p=preview
var test = $scope.$new();
$controller('Ctrl1', {$scope : test});
//the first 2 lines are executed, but the 3d never returns a value
$scope.variable = test.variable;
$scope.varFromFunction = test.varFromFunction();
$scope.varFromRequest = test.varFromRequest;
The first 2 lines execute, but the 3d one never returns a value.
Since
varFromRequest
is located inside a $timeout method in the first controller with 500ms, it will execute 500s later meanwhile angular completes its linking phase.Watching
varFromRequest
in the second controller is the easy solutionHere is the updated plunker http://plnkr.co/edit/TqSjeckrdqeKquEbCwFX