0
举个例子,我有下面的类:打字稿泛型 - 扩展类
module app.components.base {
export class BaseController<S extends IAppScope, A> {
public data:string;
constructor(public $scope: S, public service: A, public $state: ng.ui.IStateService, public $ionicHistory) {
console.log('Base Controller Loaded!');
console.log($scope);
$scope.vm = this;
}
}
}
然后,我有这个单独的类:
module app.components.properties {
export class PropertiesController extends base.BaseController<IPropertiesScope, app.services.PropertyService> {
}
}
所以,在我看来,这说的”属性控制器扩展了基本控制器,因此属性控制器应具有this.$scope
和this.$scope
应为IPropertiesScope
,因为通用类型S
继承了IPropertiesScope
接口。
但是,$scope
未在我的基类的构造函数中定义。为什么这个值是未定义的?