我想问一下当我们使用main(大组件)和子组件(最小组件)时它应该是什么样子
例如主要组件(没有htmls,在这个问题中不需要它)
export class MainComponent {
someDto = new DtoData(); // this one contains all informations to sending data
handleEventFromChildComponent() {//child component's output
if(sendToApi()) == true) {
navigateToNextStep();
}
}
sendToApi() {
if(canBeSend) {
return someService.sendSmth(someDto)
.then(() => { return true; }
}
}
canBeSend(): boolean {
return complexForm.valid;
}
}
子组件(不带html)
export class ChildComponent {
@Output('emitter') emitter = new eventEmitter();
saveButtonClick() {
this.emitter.emit();
}
}
我的一般问题是,这些组件中的哪一个应该负责将数据发送到api并重定向到下一步,我们在MainComponent中获得了dto的数据。