ng-include 上ng-controller 无法获取控件

A.Html内容如下
<div>
    <div  kendo-grid="testGrid" k-options="testOptions"> </div>
</div>

B.Html内容如下

 <ng-include  id="dashboard-section1" ng-init="init(0)"    data-ng-controller="textCtrl"  src="'/A.html'"></ng-include>

Error:
在testCtrl 中是无法使用$scope.textCtrl获取 testGrid ,是因为 ng-inclue会生成一个独立的子scope ,和controller上的scope独立开来   类似于js的原型链。

所以要在 testCtrl上的 $scope访问 A.Html的控件 则需要 像下面这样写


<div>
    <div  kendo-grid="$parent.testGrid" k-options="testOptions"> </div>
</div>

  

原文地址:https://www.cnblogs.com/Zoes/p/5551873.html