我有一个看起来像这样的承诺链......
this.getFile(fileId).then(updateFile).then(displayAllDoneMessage);
wheregetFile()和updateFile()each 用于ngResource构造适当的 JSON 调用,然后返回$resource.$promise.
链条触发正常,但我在$scope从内部访问时遇到问题updateFile
所以在getFile()我有
// this works
this.status.text = "fetching file"
但在updateFile()我有
// this fails at runtime because "this" is not $scope
this.status.text = "updating file"
我做错了什么,或者我需要做些什么才能$scope在 内提供updateFile()?
我可能应该补充一点,我正在使用 TypeScript,以防万一。