承诺后获取Injected模块属性

时间:2017-08-09 06:01:10

标签: ecmascript-6 aurelia

Aurelia FW: 我有一个模块,其属性由activate事件中的服务承诺设置:

this.httpService.get("Demo").then(response => { this.userAccountsData = 
response; this.numberOfAccounts = this.userAccountsData.length; })

我在app.html中使用该模块作为组合:

<compose view-    
model="./resources/usersAccountsCollection/usersAccountsCollection">
</compose>

然后我将这个模块注入app.js并在构造函数中获取它的属性以便检查它们:

export class App {
constructor(accounts) {
this.usersAccounts = accounts;

问题是我在promise之前收到了值(numberOfAccounts = 0)。我希望在承诺之后获得它们的值(在数据返回之后)。我很确定如果我在app.js激活事件中得到它们会很好,但我如何将结节或其属性作为参数注入激活函数?

0 个答案:

没有答案