0

我发送一个这样的事件进行删除

<child-component *ngFor = "#todo of array" [taskobject] = "todo" 
(childevent) = "deleteparent($event)">Loading...</child-component>

我如何与 childevent 一起发送另一个事件,它是用逗号分隔的吗?像这样?

<child-component *ngFor = "#todo of array" [taskobject] = "todo" 
(childevent) = "deleteparent($event)", 
(updateevent)> = "(updateparent)"Loading...</child-component>

对于编辑/更新请求,我应该向服务器请求什么 http,它是 http.put 也在服务器端吗,它是 server.put('url') 吗?

更新:

<child-component *ngFor = "#todo of array" 
[taskobject] = "todo"   (childevent) = "deleteparent($event)"
; (updatevent) = "updateparent($event)">Loading...</child-component>
4

3 回答 3

1

I think you want to handle multiple events on the same element. If so, list the event handlers separated by space, just as you would with regular HTML attributes:

<child-component *ngFor = "#todo of array" [taskobject] = "todo" 
   (childevent) = "deleteparent($event)" 
   (updateevent) = "updateparent($event)">Loading...</child-component>
于 2016-02-13T18:37:26.447 回答
0

您应该将它们分开,;但条件是如果第一个表达式出错,它将不会评估下一个表达式。但在你的情况下,这两个都是函数,所以它会按预期运行:

(anyevent)="function1($event);function2($event);etc"

这也适用于&&这样的符号:

(anyevent)="function1($event)&&function2($event);etc"

试试吧。希望这可以帮助你。

于 2016-02-13T18:42:16.267 回答
0

请改用

(childevent)="deleteparent($event);updateparent($event)"
于 2016-02-13T18:25:15.333 回答