我发送一个这样的事件用于删除
<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>
答案 0 :(得分:1)
我认为你想要在同一个元素上处理多个事件。如果是这样,请列出由空格分隔的事件处理程序,就像使用常规HTML属性一样:
<child-component *ngFor = "#todo of array" [taskobject] = "todo"
(childevent) = "deleteparent($event)"
(updateevent) = "updateparent($event)">Loading...</child-component>
答案 1 :(得分:0)
请尝试改为
(childevent)="deleteparent($event);updateparent($event)"
答案 2 :(得分:0)
您应该将它们与;
分开,但条件是如果第一个表达式出错,它将不会评估下一个表达式。但在这种情况下,两者都是函数,因此它将按预期运行:
(anyevent)="function1($event);function2($event);etc"
这也适用于&&
这样的符号:
(anyevent)="function1($event)&&function2($event);etc"
试试吧。这可能会对你有帮助。