Aurelia JS - Making a synchronous HTTP request, to change data before page load?

后端 未结 1 934
暗喜
暗喜 2021-01-26 16:27

I\'m working with the contact list tutorial:

  • http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/contact-manager-tutorial/1

... and I w

1条回答
  •  执笔经年
    2021-01-26 17:13

    Well, I finally managed to make an async call which updates the GUI, as recommended by @LStarky; note that in order to do that, one must ensure ContactList class is a single instance class, so that there is only one property contacts whose binding updates the HTML GUI.

    However, since all of this was a bit of a hacky guesswork, it would still be nice to get a proper answer from someone.

    The single instance issue described in:

    • Aurelia - accessing updated class properties from injection?

    For reference, I've left the working example saved as a gist.run here:

    • https://gist.run/?id=f4bd01c99f9973cb76d8640f6248c2e3

    ... so basically, after the two alerts, the shown contacts will get updated with the data obtained from the PHP page.

    0 讨论(0)
提交回复
热议问题