Javascript 如何访问指令中包含数组的作用域?

Javascript 如何访问指令中包含数组的作用域?,javascript,jquery,angularjs,jquery-ui,Javascript,Jquery,Angularjs,Jquery Ui,我有一个$scope包含数组,基本上我使用服务获取这些数组这是代码: var myApp = angular.module('app',[]); myApp.controller('GetItemCtrl', ['$scope', '$http', function($scope, $http) { var itemUrl = 'json/item.json'; $http({url: itemUrl, dataType: 'json', method: 'P

我有一个
$scope
包含数组,基本上我使用服务获取这些数组这是代码:

var myApp = angular.module('app',[]);

myApp.controller('GetItemCtrl', ['$scope', '$http', function($scope, $http) {

    var itemUrl = 'json/item.json';
    $http({url: itemUrl,
    dataType: 'json',
    method: 'POST',
    data: '',
    headers: {
        "Content-Type": "application/json"
    }}).success(function(data, status, headers, config) {
        //check if the response has ok status
        if(data.status == "ok"){
        console.log(data.data);
            $scope.items = data.data;
        }


        }).error(function(data, status, headers, config) {

        console.log('error');

    });

}]);
我也有一个可拖动的项和可拖放的div,基本上我只需拖动项,然后将其拖放到可拖放的div。这是可拖放的代码

myApp.directive('draggable', function() {
  return {
      link: function (scope, element) {
         $(element).draggable({
            helper: function(){
              return $("<tr></tr>").append($(this).find('.img').clone());
            },
              revert: 'original',
              cursor: "move",
            revert: "invalid",
            cursorAt: {top: 5, left: 5 } ,
            zIndex: 100,
            tolerance:"pointer",
            start: function (event, ui) {

            $(this).css('opacity', '.5');

            },
            stop: function (event, ui) {
                    $(this).css('opacity', '1');

            }
         });
      } 
    }
});
可放下的是这样的:

<div data-ng-repeat="tempElement in templateElements" class="bg-default border-solid droppable" droppable="" >
{{ tempElement.TemplateElement.elementname }}
 </div>

{{tempElement.TemplateElement.elementname}
我在我的droppable指令中尝试过这个,但是它没有改变任何东西,它也禁用了div droppable功能。我想我在某个地方出错了,但是控制台不会打印任何内容

restrict: 'E',
    replace: true,
    template: '<div></div>',
    scope: {
      items: '=items'
    },
restrict:'E',
替换:正确,
模板:“”,
范围:{
项目:'=项目'
},
有人能帮我访问指令中包含数组的$scope吗


提前感谢您的评论和想法。

显示您的html结构在指令中执行
控制台.log(scope)
,它将显示您所在的范围以及可访问的范围。对遍历这些作用域很有用。@No1\u Melman我现在就试试。@No1\u Melman我没有看到作用域
,但我看到了我使用的一些其他作用域,但没有看到你的指令,在你的控制器的作用域内是HTML吗?所以
<div data-ng-repeat="tempElement in templateElements" class="bg-default border-solid droppable" droppable="" >
{{ tempElement.TemplateElement.elementname }}
 </div>
restrict: 'E',
    replace: true,
    template: '<div></div>',
    scope: {
      items: '=items'
    },