Refactor to not climb `$parent` in Angular
Controllers in Angular should not be depending on an exact parent hierarchy. If the child controller needs information from a parent scope, it should at the very least be passed down to the child explicitly (or better yet, refactored into a Service). Climbing $parent
makes the app's parts too coupled and kills modularity. For example, the theColumn
directive in the reports app:
var the_parent = $scope.$parent.$parent.$parent.$parent;
var report_experiments = $scope.$parent.$parent.$parent.$parent.report_experiments;
var report_experiments_alias = $scope.$parent.$parent.$parent.$parent.report_experiments_alias;
var floating_point_precision = $scope.$parent.$parent.$parent.$parent.floating_point_precision;
var report = $scope.$parent.$parent.$parent.report;
var experiment_name = $scope.$parent.item;
There's more than this (just search for $parent
)