In Aurelia, can I bind a function from my containing view-model to be called by my custom element?

后端 未结 3 1823
后悔当初
后悔当初 2021-02-08 20:00

I have a custom element which will take user input, and on [save] button click, I want to pass information to the parent view-model so I can send it to the server and move to th

3条回答
  •  -上瘾入骨i
    2021-02-08 20:44

    I was able to solve this after trolling through the aurelia docs hub for a bit. I don't know all the nuances that may be involved, but for this simple example, I was able to fix it by doing the following simple change:

    In parent-view-model.html (or app.html in the gist-run example), change save.bind="parentMethod" to save.call="parentMethod()"

    I am still unsure how to pass data from the custom element into the parent view-model's method, however.

    Here is the documentation from aurelia website.

提交回复
热议问题