model.data包含以下内容:
{ "name": "Jamie","age": 25 }
我的指令看起来像:
<my-directive data="model.data"></my-directive>
我已将该指令定义如下:
app.directive('myDirective',function(){ return { restrict: 'E',scope: { data: '=' },templateUrl: 'grid.html',controller: function($scope) { console.log($scope); console.log($scope.data); } } }
问题是console.log($scope)返回$scope中的值.我可以看到它包含数据:
{ $$asyncQueue: Array[0],$$childHead: null,... ... data: Array[1] }
但是,console.log($scope.data)返回undefined.有什么线索的原因?