Angularjs 在指令中访问$scope

Angularjs 在指令中访问$scope,angularjs,Angularjs,我是angularJS的新手,所以需要一些输入。 我正在尝试访问其中一个目录中的$scope变量。我已在控制器中设置了$scope值。 下面是流程的层次结构。 Order.js定义了$scope变量 $scope.test = true; html调用另一个html <cra-violations-table violations="order.violations" on-assign-success="onAssignSuccess"

我是angularJS的新手,所以需要一些输入。 我正在尝试访问其中一个目录中的$scope变量。我已在控制器中设置了$scope值。 下面是流程的层次结构。 Order.js定义了$scope变量

   $scope.test = true;
html调用另一个html

 <cra-violations-table
       violations="order.violations"
       on-assign-success="onAssignSuccess" 
       order-status="order.statusCd" 
       edit-allowed="order.editAllowed"/>
searchpersonnelfilterctrl在
filtercomponent.js
我正在尝试访问
filtercomponent.js
中的变量

.directive('searchpersonnelfilterctrl', function() {
    return {
        restrict: 'AEC',
        scope: {
            class: '=class',
            title: '=title',
            searchCtrl: '=searchCtrl',
            placeholder: '=placeholder',
            typeahead: '@',
            typeaheadTemplateUrl: '@?'
        },
        templateUrl: 'includes/filter-component-search.html',

        compile: function(element, attrs) {
            // Set default values
            attrs.$set("test", "$parent.test");
          }
但它是未定义的。 谁能帮我一下吗。
谢谢

请分享指令代码的相关部分。为什么不通过测试变量作为指令的绑定?”@PanosK是的,我可以这样做,但是更改filtercomponent.html后的imapct太多了..我们不想触及这一点..您无法在编译中获取范围,只能在链接中获取
.directive('searchpersonnelfilterctrl', function() {
    return {
        restrict: 'AEC',
        scope: {
            class: '=class',
            title: '=title',
            searchCtrl: '=searchCtrl',
            placeholder: '=placeholder',
            typeahead: '@',
            typeaheadTemplateUrl: '@?'
        },
        templateUrl: 'includes/filter-component-search.html',

        compile: function(element, attrs) {
            // Set default values
            attrs.$set("test", "$parent.test");
          }