Let's say I'm loading a variable into $scope with $http:
$http.get('/teachers/4').success(function(data){
$scope.teacher = data;
});
My template uses this data:
Teacher: {{teacher.name}}
<students-view students="teacher.students"></students-view>
This directive can load BEFORE teacher finishes loading, but my directive has code that depends on the teacher.students array being loaded:
app.directive('studentsView', function(){
return {
scope: { students: '=' },
controller: function($scope){
_.each($scope.students, function(s){
// this is not called if teacher loads after this directive
});
}
};
});
How do I get the behavior that I want here? I don't want to stop using $http, and I would like to not have to assign a promise to the scope if possible.