Angularjs 访问角度控制器外部的typescript全局变量
我在main.ts文件中有一个名为Angularjs 访问角度控制器外部的typescript全局变量,angularjs,typescript,Angularjs,Typescript,我在main.ts文件中有一个名为rowTag的全局变量作为Tag[]实体的数组 我有一个叫做TagMeController.ts文件的角度控制器 这是TagMeController constructor($scope, $rootScope) { $scope.CloseMe = this.CloseMe; $scope.rowTags = rowTag;//rowTag global variable $scope.c
rowTag
的全局变量作为Tag[]
实体的数组
我有一个叫做TagMeController.ts
文件的角度控制器
这是TagMeController
constructor($scope, $rootScope) {
$scope.CloseMe = this.CloseMe;
$scope.rowTags = rowTag;//rowTag global variable
$scope.colTags = colTag;//colTag global variable
$scope.UpdateMe = this.UpdateMe;
}
因此,当我从同一个控制器更新rowTag
对象时,它会更新UI上的各个元素,但当我从另一个.ts(main.ts)
文件更新同一对象时,不会反映出任何东西
你知道如何让这个变量可见吗
你知道如何让这个变量可见吗
创建一个包含该信息的角度服务
class Tags {
rowTags = []
colTags = []
}
然后使用该服务:
constructor($scope, $rootScope, tags: Tags) {
$scope.CloseMe = this.CloseMe;
$scope.tags = tags; // Tags service containing `rowTag` and `colTag`
$scope.UpdateMe = this.UpdateMe;
}
这是一个关于使用TypeScript创建角度服务的视频:您能添加更多详细信息吗?