I have a directive that looks like this (irrelevant parts omitted):
app.directive('rgReportContainer', function() {
return {
restrict: 'E',
scope: {
projectIds: '='
},
controller: controller
};
controller.$inject = ['$scope'];
function controller($scope) {
$scope.$watch('projectIds', function(projectIds) {
console.log(projectIds);
});
}
});
The value for projectIds
starts off as []
, and so the first thing that's logged is []
, as I would expect.
What's confusing is that projectIds
is populated after a moment by an XHR request, but the value is never picked up.
My template looks something like this:
{{ reports.included_project_ids }}
<rg-report-container project-ids="reports.included_project_ids"></rg-report-container>
I can see in the template that reports.included_project_ids
goes from being empty to not-empty. There's a point at which I can plainly see that reports.included_project_ids
has data, but at that point, my $scope.$watch
isn't picking up the new value.
Any help is very much appreciated.