change your onCallComplete from
var onCallComplete = function(data) {
$scope.user = data;
service1.getRepos($scope.user).then(onReposComplete, onError);
};
to
function onCallComplete(data) {
console.log(data);
$scope.user = data;
service1.getRepos($scope.user).then(onReposComplete, onError);
}
Here is the working plunker
or move your service1.getUser($scope.username).then(onCallComplete,onError); beneath onCallComplete like given below.
var onCallComplete = function(data) {
$scope.user = data;
service1.getRepos($scope.user).then(onReposComplete, onError);
};
service1.getUser($scope.username).then(onCallComplete,onError);
The Reason is When you define your function as var onCallComplete =function(data) the function definition happens at runtime. but using function onCallComplete(data) the function gets defined while parsing the script.So it would be available at any point during runtime.