Javascript 监视父作用域,ng包含在typescript中

Javascript 监视父作用域,ng包含在typescript中,javascript,angularjs,angularjs-scope,typescript,Javascript,Angularjs,Angularjs Scope,Typescript,我正在尝试查看子模块中的父属性 我有这样的html和html <div ng-include="maincontainer.selected"></div> 我想在我的ChildViewController中查看“var”父属性 class ChildView { scope: ng.IScope; static $inject = ['$scope']; constructor($scope: ng.IScope) {

我正在尝试查看子模块中的父属性

我有这样的html和html

<div ng-include="maincontainer.selected"></div>
我想在我的ChildViewController中查看“var”父属性

class ChildView {
     scope: ng.IScope;

     static $inject = ['$scope'];

     constructor($scope: ng.IScope) {
        this.scope = $scope;

        // Here I want to add a watch to the parent property.
     }
}

有人能帮我吗?

支持Jahongir在上述评论中提出的观点

您可以为正在注入的内容创建自己的接口,该接口将具有所有$scope,但允许$parent为任何类型:

interface IMyControllerScope extends ng.IScope {
  $parent: any;
}
然后将$scope声明为新接口,该接口在$parent上定义var

constructor($scope: IMyControllerScope) {

您是否尝试过
$watch
$parent.var
?问题是typescript无法识别var的名称,并且无法传输。很抱歉,我不知道typescript。但是也许会有帮助。谢谢你,但是这个链接并不能解决父作用域的问题,只针对自己的作用域。
constructor($scope: IMyControllerScope) {