【发布时间】:2015-08-04 06:36:06
【问题描述】:
如何在 typescript-class 中访问父 Controller 的范围?
这是我的代码:
export class EntityOverviewCtrl extends AbstractCtrl {
public static $inject = ["$state", "$http", "CurrentSession"];
public EntityName: string;
public Records: any[] = [];
constructor($state, $http, $parent, protected currentSession) {
super($state, $http);
this.init();
}
}
我正在使用 UI-Router,但此处没有可用的 $scope.$parent-Variable...
【问题讨论】:
-
你可以在你的控制器中注入 $scope。你为什么不这样做?
-
我试过了,但没用。$scope 总是未定义的。我将“$scope”添加到注入变量中,并将 $scope: ng.IScope 添加到构造函数中,但没有运气
-
您可以发布该代码吗?我怀疑你做错了什么。否则它应该工作
-
抱歉,另一个类中出现错误,VS 没有重新创建我的 Javscript 文件。我必须在继承 EntitiyOverviewCtrl 的其他类中包含 $scope。感谢您的帮助
标签: angularjs typescript